You're baking in a lot of assumptions in the statement "profitable overall". I take it that you mean "benefits society in a way that more than makes up for its cost" but a private company doesn't care, they naturally want immediate or (relatively) short-term profits. A country's first trans-national railway is naturally almost always a net benefit, to take an example, but it's too expensive for the private sector to build alone and almost certainly wouldn't be properly profitable for decades until the infrastructure grows around it.
Some infrastructure or public service building also facilitates something else indirectly, or over a long enough time that it wouldn't feature into any direct calculus. The same goes for services. And how does one quantify this "profitable overall" requirement? This is why big projects are often ultimately a political choice, lambasted by businesses and economists, which often (but not always) are greatly appreciated in hindsight. That shouldn't be carte blanche for people to go out and spend tax money, but it illustrates a certain dilemma.