I've heard about stories about government agencies and such second hand from family members. To me, it sounds like it breaks down to this because the projects that they are running are not subject to risk of failure. There isn't a small company that is going to absolutely die if a deliverable doesn't meet the market's demands at a certain point in time. Just don't stop throwing money and resources at the project until it is done no matter what.
Government projects are about as efficient as similarly-sized projects in the private sector. You just never hear about private company’s failures because the public has less of a stake in it. Journalists focus on people wasting your money.
The laws requiring publication of bidding documents and damning reports on cost overruns are also mostly specific to public projects. Who knows how much money Apple invested in self-driving technology? Try sending a Freedom of Information Act request to Uber inquiring on their self-driving car efforts.
It is a little more complex. The small company realizing money will run out will start to look at options. The obvious option is cut back requirements/scope until they can get something - anything - on the market to bring in money. If they can slow the rate of losses they might be able to finish eventually. The other option is to show their investors current progress and ask for more money - this is a hard sell but it sometimes works.
In government the first is not allowed - the contract is specified. However you can ask for more and if you have made progress they will sometimes grant you "that little bit more" - remember ultimately they want what you are under contract to make and if you fail they have to start over again with someone else.
As somebody else has remarked, your perception is somewhat skewed by survivorship bias: yes, it seems that these cost overruns are due to a lack of “risk of failure”, but one should really compare it to the overall manner by which capital is allocated and products delivered to market, meaning that one should not be blind to all the startups that get funded and fail to deliver. I'm not saying the two systems are equivalent, but this is the information you must keep in mind to compare them fairly.