The roots of the Mexican-American War actually began with the end of the Texas War of Independence. Mexico never recognized the independence of Texas, despite the fact that the international community had, so when the U.S. annexed it as a state in 1845, Mexico broke all diplomatic ties with the U.S.
When the U.S. inherited Texas, they also inherited long-standing boarder dispute with Mexico. The Mexican government had determined that the Nueces River was the boundary between Texas and Mexico while Texas and U.S. maintained that the more southern Rio Grande was in fact the real boarder. With no diplomatic exchanges between the two countries, it was only a matter of time before a conflict erupted over this disputed boundary.
President James K. Polk also had designs on California. After a few failed attempts to purchase or swap for the territory, Polk decided that war was the surest way to solve the boundary dispute and also complete his vision of a cross-continental American Empire. In June of 1846, Polk ordered American troops over the Nueces river and south to the Rio Grande, an action that Mexico repeatedly warned Polk would be considered an act of war. American soldiers eventually came into contact with Mexican cavalry and after a brief firefight that left 16 Americans dead, Mr. Polk had his war. After a fiery speech to congress where Polk claimed that, “American blood has been shed on American soil,” the U.D. declared war on its southern neighbor and the war was on.