Taking healthcare for example, the incentives of the buyers (patients) and sellers (doctors) are inherently conflicting, as the former seek health, while the latter benefit when the former are sick. Furthermore, the patients very often urgently need help and don't have the time (nor the knowledge) to "shop around".
Or education. The "value" of a college is the increase in lifetime income vs. a high-school education, but given the slow feedback cycle (30 years or so of working) the market equilibrium is trending towards the price of college being the discounted value of all discretionary income of the graduates. This is aided by the US government that guarantees the loans and prevents them being discharged in bankruptcy.
A similar field is also infrastructure.
None of these fields must inherently be constrained by the government, but they need to be regulated in such a way that a free competition is encouraged.
That's trivially true of almost every market. People want food but restaurants benefit when the former are hungry!
People getting sick is not a basic need unless you are a healthcare company. That's why the incentives are conflicting.
Getting hungry again happens naturally regardless of the choice of food offered by a restaurant.
Whether you remain sick, are cured, or get sick again depends significantly on the choice of treatment offered. Healthcare companies have an incentive to choose treatments that don't cure you.
Individual humans may have other things that motivate.
There's this idea that certain classes of activity are "too important" for profit-motive to be allowed. Education, healthcare, science, and agriculture usually fall in the line of fire. These people cheer on the companies that make their money in advertising or solving first world problems and demonize those that work on the capital-intensive problems in healthcare, science, or agriculture. Then they loudly complain about how the best of the best are going into the wrong lines of work. It's bonkers.
Moral tale: my brother was at the top of his class at an Ivy-league school and got his degree in physics. He did lab research on nanotechnology since high school. He seriously considered getting his PhD in physics. I counseled him to go to Wall Street instead, which he did. Now he makes a bunch of money and couldn't be happier.
What's my point? Getting a PhD in a hard science should be a license to print money like going into advertising or finance. Until that's true, you're not going to get the allocation of social resources you want. And government research isn't a solution to that. You'll never make a bunch of money working for the government. And if e.g. the government lets people keep the patents on research that's initially publicly-funded, so they can make a bunch of money on the endeavor, then the aforementioned people will demonize that as evil.