San Miguel de Allende became a Mexican national monument in 1926, and a UNESCO World Heritage site in 2008, which helped a lot with preserving the colonial architecture and character of San Miguel, particularly the town’s historical central areas.
During the colonial days, income related to the silver mines of Guanajuato (most within about an hour and a half from here by car) largely financed the beautiful architecture you see in San Miguel de Allende. After the mining era, San Miguel became, for all practical purposes, a ghost town. As a result, unlike the other places in Mexico that I call “classic examples of urban planning run amuck,” San Miguel de Allende doesn’t have huge contemporary stores with neon lights next door to beautiful historical buildings.
So, San Miguel’s historical architecture got preserved well before most of the town’s post-colonial era growth and development occurred, and the foreign as we'll as indigenous local residents zealously strive to protect this.
(Pictured: San Miguel de Allende skyline, showing church and architecture.)