Why does Mexico City sometimes experience freezing temperatures even though it is in the tropics?

Mexico City is not located in the tropics. The tropic of cancer passes North of Mexico City so while it is considered sub-tropical, it is also at a very high elevation which leads to its cooler climate.
Copyright Wanderlust World © https://www.ynyoo.com