Government basically represents society as a whole, as it was elected by the public. It provides services to society that are NOT profitable for private enterprise...military, infrastructure, education, etc. Therefore instead of asking whether "government" can afford something or whether it can turn a profit, we should instead be asking whether "society" can afford something or whether it can turn a profit (i.e. if the economic benefits outweigh the costs).
This notion of profits is ridiculous when it comes to government spending. The costs of a high-speed rail system are born by society; government is merely the vehicle through which they are collected. The benefits, on the other hand, accrue directly to society without passing through the government coffers first. By that measure, of course it's not going to be "profitable" if you're merely looking at the government's balance sheet rather than how it affects the economy as a whole.