You're basically interviewing to study under an existing doctor in a particular specialization for a period depending on the exact specialization, but minimum 2 years and I believe up to 5 years (you have to interview and get hired for this job). After that, assuming the guy/woman you studied under supports your application, you get your medical licence. The issue is interviewing successfully without support from a US institution.
For a lawyer it's much simpler : either you interview and get hired by a company, or you take the bar exam. Exactly the same process as US citizens (you do need a valid work permit - but that would be required for actually doing any law work anyway - although it can delay things). I know 2 lawyers doing cases in the US that aren't US citizens.
In the case of pharmaceuticals, there probably isn't a free market at all. Regulatory capture has happened, and we're seeing the end result.
In other things, the idea is "globalization for me, but not for thee". That is, ship US IT jobs to India or Viet Nam or where ever, but keep lawyers and doctors scarce in the US, and forbid bringing in cheap subsitutes. Or perhaps region codes: keep prices high in US and western Europe, but allow lower prices for Africa and South Asia, via DRM.