Because when a doctor prescribes Percocet and you go to a pharmacy to get it, you don't accidentally end up with fentanyl instead. That only happens when you buy it illegally from a dealer.
Also, doctors normally don't prescribe percocet or other strong opiates to "take the edge off" (i.e. psychiatric treatment). That's what barbiturates and anxiolytics are for.