Let's say you want to build a road that connects 12 houses. You can do that without the government. You just need everyone to agree on who contributes what, who you hire to do the work, what happens if something goes wrong, who else is allowed to drive on the road, how maintenance happens, who polices the rules, and so on, and so forth.
This does occasionally work out in real life, but mostly people bitterly argue over the whole thing and it never happens. Having a government set some sort of policy and doing the planning is usually far more effective, even if it pays more than is necessary for the actual work that gets done. The government may pay more per mile of road, but the road has a higher odds of getting built.
"The government" is not a singular entity, it's a collection of tens of thousands of smaller entities, all of which operate mostly independent of one another and whose relative "efficiency" is based almost entirely on the people working there. One town may have a school or fire department which operates extremely well under a very tight budget, while the town over might poor money into a corrupt and expensive institution which fails to provide more than basic services.
In this respect, it's no different than any other business. Some Walmarts are clean, tidy, and well run, others are a mess. But you wouldn't go around claiming that "The retail" is inefficient because of this fact.
Also, not every government department should be efficient. The military is often held up as the hallmark of an inefficient bureaucracy, but the fact is, we don't want a military that's cost-effective, we want a military that's combat-effective, no matter the cost. But we also have a post office that can mail a letter to the middle of Alaska for less than a dollar.
Your comment about the market working better at "this" (whatever this is, anyway) is equally as lazy.
Governments are monopolies. The only incentive they have to be efficient is the leadership changes that possibly occur with each election cycle. Given the wide range of services and issues that governments must tackle, it's likely that voters have only a few key issues in mind when they go to the ballot box. With each change in leadership, a different set of priorities takes precedence. Sometimes long standing, mediocre services, continue unabated and unimproved for decades at a time with little to no innovation.
The evidence that this stereotype is true is overwhelmingly strong, so, it's perfectly legitimate to set policy around it.