Most people who share their prescription medications are not trying to do anything malicious. They're not attempting to give medications to someone who is addicted to them, for instance, and they are certainly not attempting to sell them for profit. All they are trying to do is help. They genuinely mean well.
This often happens between friends and family members when two people have similar symptoms or a similar condition. One person already has the medication in their possession, thanks to the prescription they got, and the other person would like to try it before they go to the doctor or they need it immediately. They may also say that it's too expensive for them to go get a prescription, but they think that the medication would help.
Feeling compassion for them, their friend or family member gives them the medication. This sounds fine at the time, but it can carry serious legal ramifications.
The problem is that sharing prescriptions is still illegal because prescriptions are written to one specific individual for one specific medication. That medication can only be used in this manner. If you give those prescription drugs to someone else, even if you don't sell them for profit and have a valid prescription yourself, this can still be seen as a drug offense because the other person was not supposed to have that medication. It is still a controlled substance under the law.
If you find yourself facing some serious charges over a mistake made with the best of intentions, be sure you understand what legal options you have.