Residential housing affordability stress is an important catalyst of class solidification and the growing worldwide social divide. Based on a quantitative spatial model that considers government utility and decision-making and uses nighttime lighting data, this study utilizes potential urban footprint as an instrumental variable to examine the mechanisms underlying the effects of the urban form on housing affordability stress and the moderating effect of government public service expenditure efficiency. The theoretical model and empirical results indicate the following. (i) The compact urban form increases housing affordability stress through productivity and urban living amenities. (ii) The efficiency of government public service expenditures affects industrial agglomeration externalities and public service accessibility, precipitating a negative moderating effect on the relationship between urban form and housing affordability stress. (iii) Based on LandScan data, a polycentric layout was found to weaken the compact urban form's ability to reduce housing affordability stress and reduce the government spending efficiency's negative moderating effect on public services. These findings demonstrate that the positive externalities of agglomeration production and the rationalization of government public service expenditures play important roles in housing market stabilization, which is helpful in facilitating better resource factor allocations by the government in the urban sprawl process.