This is a really dumb way of thinking about how the government spends money. A corporation does not need to make a profit: it needs to make a profit now. And not just now, but also high enough.
Governments are special in that they can finance things which bring in enormous profit in the very long run (fundamental research, very large infrastructure projects) or which have very large positive externalities (free roads). Without governments, you could not build dams: large ones become profitable after 50 years. No bank, no insurance company will accept such long-term risks: they may well not exist that long. Only countries can be reasonably certain of existing within such stretches of time.
TL;DR; it is an essential function of governments to fund long-term, high-risk projects.