Because they don't have to pay for their education. Governments there recognize that having lots of doctors is a public good and don't saddle them with hundreds of thousands of dollars of debt from medical school.
Doctors aren't the ones who pay that medical school bill (if they get a job). It's their patients who pay the medical school bills.
The problem of medical expenses in the US is a very complex one. It's essentially at the nexus of a whole bunch of problems with our society. Higher education is too expensive. We have too many middlemen. Strong intellectual property laws make drugs and devices expensive. Patent laws make evergreening more profitable than innovation. Intense regulatory requirements for approval make competition very limited for pharmaceuticals. The government doesn't maintain control of the products resulting from the blue-sky R&D it funds. etc etc.
Healthcare in the US is a scam. There's no other way to look at it.