Urban resilience is crucial for sustainable development and resident safety in a changing environment with potential risks. Given China’s rapid urbanization, constructing resilient cities that anticipate risks, mitigate disaster impacts, and swiftly recover from crises is paramount. This study explores a key area of urban construction: building safety. We apply the dynamic nonhomogeneous grey model (DNMGM(1,1)) to simulate the building death toll and use a traffic accident death toll dataset for validation. Unlike traditional models, DNMGM(1,1) can integrate and respond to new data points in real-time, thus producing accurate predictions when facing new trends or fluctuations in the data. The research findings indicate that with a dataset size of 6, the DNMGM(1,1) model achieves average relative errors of 9.26% and 7.29% when predicting fatalities in both construction and traffic accidents. This performance demonstrates superior prediction accuracy compared to traditional grey models. This method uses prediction models to support the construction of elastic cities, providing strong data support and decision-making tools for planning and resource allocation. Specific interventions and policy frameworks based on this study by urban planners and policymakers can promote resilient urban development. Future efforts should strive to enhance its robustness and adaptability in different fields.