It has often been observed that the US was woefully unprepared for war when in 1851 they declared hostilities with Mexico. Mexico was a united country that had just come out of the Civil War strong and with renewed purpose. The aristocrats, clergy, and centralists that had sided with the rebels were defeated, and though the nation mourned the assassination of President Farias, the work that he had done for the victory of progress and the rebuilding of infrastructure, as well as the trial by fire through which the army had gone and the generation of great generals that had been created, would live on to drive Mexico into the world as a Great Power.
This is in contrast the the United States, which was a terrible name for such a disunited polity, with cultural and economic fractures beginning to form at so many points, and an army and navy that were languishing, the US was gearing up the face itself, not the world. Not to mention the ridiculous slavers in the US south, who made half the country an oppressive, backward, unproductive hell-hole. The country had few experienced military leaders left since its last war in 1812, and its economy was also starting to fall into disarray.
The US's tactics were ill-suited to the ground they were fighting on, with the rugged mountains of California and the deserts of New Mexico and Texas providing excellent defensive potential while hindering attackers. The age-old advantage of the home ground, where the defenders might have accurate maps and knowledge of the terrain, while the attackers may be relying on out of date or erroneous knowledge provided by locals with no love for them. The US Army was as disunited as the country as a whole, as oppressed peoples who had emigrated to the US, like the Irish and Poles, flocked to Mexico's banner in droves.
All Mexico had to do to win was preserve its territorial integrity, while the US had to conquer the vastness of northern Mexico to achieve its aims, not even mentioning having to subdue Mexico proper in the south, whose marshes and swamps, hot climate and dense population gave the UK such hell in 1871.
I'm surprised that anyone, even Americans, would see any chance for the US to win. Mexico had all the winds and dragons, the outcome was nigh inevitable.