It doesn't have to turn a 'profit' in the literal sense, but it needs to make more money than their current spending because they have to pay future pensions.
For instance, my family's street recently got a public sewer system (to replace septic systems), and the city charged homeowners one-time and recurring fees to cover the expenses of both installation and operation. If the city could not get the homeowners to pay enough to cover the cost of the sewer system, which was a real risk, the system would have been considered a mistake (and a project with similar economic prospects would likely been avoided in the future).
The big-ticket items I pay for as a taxpayer include schools (via local taxes), defense, retirees, and healthcare. None of those cover their expenses, and basically everything else combined is a tiny minority of government expenditure.
(I believe we should more fully fund the non-defense parts of the budget, but let's not pretend they net out in the in-years.)