It's a bit more complicated than that. R&D for new drugs is incredibly expensive while the cost to actually produce most drugs is reasonably low.
The price of drugs that make it to market needs to not only cover the cost to produce the drug, but also the cost of R&D and the cost of R&D of all the drugs that fail to get to market.
Now this gets complicated when a company sells in different markets with actors that have different negotiating power. It makes sense to sell in any market where the company can get a profit per unit sold without including R&D. But if none of the markets allow enough profit to cover R&D, then it's not really worth developing any new drugs at all anymore.
That's why people say that the US is basically subsidizing drug development. It's not that it's not profitable to sell in the rest of the world, it's just that margins are much lower which allows for a lot less risk-taking on R&D.