Medicare didn't provide coverage for prescription drugs until the adoption of Part D. That is structured differently than other parts of Medicare. Instead of the government serving as the insurer directly, the government subsidizes premiums for a private Part D insurer. The private insurer can and does negotiate drug prices.
The fact that Medicare can't negotiate prescript drug prices is often invoked as a talking point, but Medicare prescription drug spending accounts for a relatively small proportion of. overall Medicare spending: https://www.heritage.org/medicare/commentary/good-and-bad-id... ("Consumer choice and competition have made Part D the rarest of government programs: one in which spending hasn’t spiraled out of control. In fact, government actuaries report that federal general revenue spending on the program was $67.8 billion in 2018—that’s less than what it spent in 2015 ($68.4 billion).").
A point in case is the Hep C vaccine: https://www.medicalnewstoday.com/articles/323767#drug-types-...
There is an issue with some old out of patent drugs that costs a lot despite being very cheap to manufacture, but that typically has to do with FDA certification deciding who can be allowed to produce what, which is also expensive to obtain.
I'll admit that profit seeking would work better* in a society that doesn't have a strong state or other coordinating body, but given that one exists to counterpose our existing system is not reasonable.
EDIT: * In the sense that products might be produced at all. Without a strong regulatory body, the market would be flooded with snake oil medicine and the average consumer would not be able to make heads or tails of things. This is because it's much cheaper to make a fake medicine than a real one, which is what profit optimizes for: the cheapest solution with the highest payoff for the seller regardless of costs not borne by the seller (such as death and destruction writ large).
Had to get an MRI and the lab corporation that performed the MRIs said that it would be ~$850 if billed through insurance. This included the total cost minus what was covered by insurance so the initial cost of the procedure was in the ~$1200 range. BUT, then they said if we just paid them directly and they didn't have to bill through insurance it would only be $650. So our insurance didn't even cover the absolutely ridiculous amount of overhead that was added just to deal with our insurance provider.
I have no sympathy for them whatsoever.
Other times with chronic conditions where theoretically price discovery could help, the problem is that you need care badly so all the chronic care providers jack up the prices super high beyond what is needed. Treating this as a market in any way is a crazy system. If the government pays market rate, they jack it up even more. So the solution has to be that the government has to set the prices either directly or by negotiating with an entire population at its back and no competitors (i.e. monopsony in the public interest).