Slavery was a source of friction between the anti-slavery Mexican government and slave-owning Texan immigrants, eventually contributing to Texas defecting to the United States. But Mexico was founded as a Spanish colony whose economy relied on Native American slave labor. What changed in the centuries between Hernan Cortez and Davy Crockett?
Slavery was legal during the colonial period, but after 1542 (only 21 years after the conquest of the Aztecs) indigenous slavery was outlawed by the king in a famous series of laws called the New Laws. Indigenous persons were still subject to paying tribute and providing corvee labor to the state. African slavery was legal throughout the colonial period, but in Mexico at least its importance declined rapidly after the 17th c. and by the time of independence Mexico probably had no more than several thousand slaves.
Slavery was formally outlawed by the Mexican state with independence. In Latin America the presence or absence of slavery as a major economic system determined when abolition occurred. Those states, which like Mexico, were not dependent on slavery tended to abolish it with independence or shortly thereafter. Those that were heavily reliant upon slavery (Brazil being the clearest case) tended to delay (just like in the USA).
For a good book on the African experience in Latin America see, African Slavery in Latin America and the Caribbean
For the Black experience after independence see Afro-Latin America