At the start of the war, Mexico was pro-German. But this changed when Germany attacked the USSR, angering Mexican leftists. Mexican anger at Germany increased when the Germans torpedoed a clearly identified Mexican tanker in May of 1942. Mexico issued an ultimatum to Germany, but the Germans sank another tanker 12 days later.
At this point, Mexico declared war on Germany. Mexico was not seriously involved militarily in the war. It did create one air force squadron that was sent to operate with the US in the Pacific Theater. It did see some combat in 1945.
Outside of that, Mexico's main role was to supply important minerals to the US. It supplied such things as copper, lead, mercury, and cadmium. This was the most important part that Mexico played.