Having the population located in dense urban areas is more efficient and therefore cheaper in terms of the real resources that are required: infrastructure is cheaper to build, distances are smaller so that less time is wasted commuting and transport is cheaper (not to mention that highly efficient public transport becomes viable).
So in real resource terms, urban sprawl is more expensive.
But since land is still a limitation and zero-sum, competition can drive up housing costs in attractive dense urban areas to the point where it more than cancels out the efficiency gains of the urban density, and the cost of living in the urban area to the individual becomes higher than the sprawl.
This is why some sort of collective planning is required to make sure that as much as possible of the efficiency gains of urbanization are actually realized. This means having proper infrastructure mostly in terms of public transport.
(Of course, the other part of it is that you need to be careful not to look at just housing costs in the first place. For example, I don't even have to pay for a car, and I benefit from city infrastructure in many other ways.)