You’re right about what happened, but not for the wholly right reasons. The hospital charged you so much because they have to also negotiate prices with insurance companies (health insurance companies are just for-profit government agencies, they don’t actually serve a market value today) and pay for those who are uninsured. There are for-profit healthcare systems of course, but that’s only part of the story.
If the cost of the doctor’s time and the medication was $100, they can now cover let’s say 3 uninsured people for $300 each then take the other $300 you paid and book that against someone going bankrupt or a difference in negotiated cost with the insurance agency.
In America we have privatized profit for the insurance companies and socialized loss. They deny a claim, book a profit, the person with the claim doesn’t get treatment, then can’t work, then needs care, and society pays for it.
Purely from a cost perspective we should just go to single payer, but we won’t do that because who is going to the the politician that causes 10s of thousands in job losses of highly paid white collar professionals?