We have to keep in mind that, at the time, Mexico was going through a period of civil war and foreign invasion, so it is useful to examine the way that the Confederacy related to each of these governments: Benito Juarez's Republic; the Mexican Northern States; and the French-backed Second Mexican Empire.
The Juarez liberal government didn't recognize the Confederacy because of their close ties to the US and because of the many Confederates' territorial ambitions in Northern Mexico. The US was Juarez's main ally during the Mexican civil war known as the Reforma (1858-61), providing him with diplomatic recognition and loans to finance the liberal war effort. Besides, several Confederate politicians had expressed a desire to annex parts of Northern Mexico, which caused concern in the Juarez government. As a result, Juarez not only did not recognize the Confederacy nor support it, but actively worked against it by allowing US troops to cross the Mexican border so as to facilitate their offensive against the Confederacy in Arizona.
On the other hand, the Northern States had more amicable relations with the Confederacy, although they never officially recognized them. This was a result of the weakness of the Juarez government in the North, which allowed several Northern politicians a higher degree of autonomy from the Republic. For example, the governments of Chihuahua and Sonora received Confederate diplomats with no regard for the Republic's official stance. But probably the most famous example was that of Santiago Vidaurri, governor of Nuevo Leon and Coahuila and an enemy of Juarez. Vidaurri was against allowing US troops in his territory, allowed trade between Nuevo Leon and the Confederacy and had normal diplomatic relations with the Confederates.
In a similar fashion, the Second Mexican Empire had cordial relations with the Confederates, but the Empire was always careful with their interactions so as to not cause conflict with the US. The Empire, which had the support of Mexican conservatives and of Napoleon III, sought to defeat Juarez's Republic and impose a monarchy in Mexico ruled by a European prince, Maximilian of Habsburg. Since both Napoleon and the Imperial government were aware that, once the US Civil War was over, the US could declare war on the Mexican Empire to uphold the Monroe Doctrine, Napoleon adviced Maximilian to be very cautious with the Confederacy. As a result, Maximilian never recognized the Confederacy, and even tried to obtain recognition from the US, but failed. After the war, as Confederates were seeking refuge in Mexico and the idea of Southern colonization started to gain popularity among supporters of the Empire, Maximilian tried his best to deal with the matter in a way that would not create tensions with the US; eventually he allowed Southerners to colonize certain parts of Northern Mexico, but the Empire's collapsing government made the process almost impossible.
References: Hanna, A. J., y Hanna, K. A. (1971). Napoleon III and Mexico: American Triumph over Monarchy. University of North Carolina Press. Hanna, K. A. (1954). The Roles of the South in the French Intervention in Mexico. The Journal of Southern History, 20(1), 3-21. https://doi.org/10.2307/2954576 Rippy, J. T. (1919). Mexican Projects of the Confederates. The Southwestern Historical Quarterly, 22(4), 291-317. https://www.jstor.org/stable/30241764