Earlier studies have examined various factors that may contribute to the contagion rate of COVID-19, such as urban climatic and socioeconomic characteristics. However, there is a lack of studies at the township level detailing the spatiotemporal settings of built environment attributes, especially in the context of lockdown as a response to the global Omicron outbreak. In this study, we extended the existing literature by relating the initial-stage Omicron pandemic conditions with more comprehensive measures of the built environment, including density, diversity, design, distance to transit, and destination accessibility. The variations from the confirmed clusters of COVID-19 and asymptomatic infected cases before, during, and after the lockdown throughout the Omicron outbreak were identified geographically using GIS methods in 218 township-level divisions across Shanghai during the lockdown period. We also compared the regression results of the ordinary least-squares regression, geographically weighted regression, and geographically and temporally weighted regression. Our results show that (1) among all the built environment variables, metro line length, walking accessibility, hotel and inn density, and population exhibited positive significance in influencing pandemic prevalence; (2) spatial and temporal variations were evident in the association between accessibility, mobility, density-related built environment variables, and COVID-19 transmission across three phases: pre-lockdown, during lockdown, and post-lockdown. This study highlights the importance of targeted public health interventions in densely populated areas with high demand for public transit. It emphasizes the significance of transportation network layout and walking accessibility in controlling the spread of infectious diseases in specific urban contexts. By considering these factors, policymakers and stakeholders can foster urban resilience and effectively mitigate the impact of outbreaks, aligning with the objectives of the 2030 UN Sustainable Development Goals.