I don't think a Mexican victory is anyway near possible, they were outgunned and outnumbered, fighting over territories that didn't even want to be part of Mexico in the first place. Mexico couldn't even keep Texas from succeeding. It took them 7 years just to defeat Yucatan, and they only managed that because Yucatan couldn't defeat the natives. There was no possible way that Mexico could actually walk away from a war with the United States, already a formidable power, with anything even resembling a victory.
True, Mexico was weak. But I don’t think the US was a formidable as you imply. Rather, the USA was relatively formidable in the minor league sense and comfortably far away from Europe- home of the military major leagues and big wars against viable opponents. The successes of the American Revolution noted, invasions of foreign nations via expeditionary forces are tricky, even for experts (Napoleon takes the witness stand). The US invasion Canada, though not a Moscow disaster, did not go so well.
In short, the small US army and supporting “fair weather” militias and security contractors were taking a big risk when they landed in Veracruz and marched west into the Mexican heartland. I don’t think it would take ASB level intervention to give that force a nasty surprise outside of Mexico City and bog down the grab bag of invasion forces marching overland from Texas.
Sure, some things would have to change….
- Mexicans in Mexico proper would need to perceive the war as the defense of home, culture and religion- and be willing to pay for that defense in fatalities.
- The Mexicans would need put their pride aside, seek and actually heed expert advice. Fortunately, such advice was available in Europe in the form of expert military officers from UK, France, Italians states doubling as security advisors / combat leaders for hire.
I am thinking….
France and UK perceive US extraterritorial hungers as threats to their holdings in the Caribbean, Belize, and as a threat to the UK Dominion of Canada. One, or both nations, provides Mexico with teams of expert advisors. Mexico is also allowed to purchase a certain number of modern artillery and muskets at “friendship prices” with “friendship” bonus items. The Mexican populace mobilizes for a people’s war to be fought in Mexico proper, not in fringe territories of dubious loyalties. The people' s units are leavened by some well-trained units under expert advice.
The inland result is Napoleon on a smaller scale. Sure, the US force is better trained and better led- but that does not matter much in the attrition battles on the way to Mexico City. There are a lot of lean, mean bushwar fighters in US ranks, but this is not a bush war of manuver against numerically doomed native american foes. Rather, the war is fixed attrition battles against a numerically strong opponent- very un bush like and very disturbing to bush fighters.
Each "victory" takes a toll on the invaders. The morale of U.S. militias and security contractors starts to waiver. Things get bad outside Mexico City where still another people's army leavened by additional well trained and well advised / led Mexican forces is waiting. They get
really bad on the retreat back- illness, thirst, desertions, guerillas, contaminated wells, a pursuing Mexican army that does not care about losing individual battles, Lancers going after stragglers... .