On May 13, 1846 the United States Congress passed An Act providing for the Prosecution of the existing War between the United States and the Republic of Mexico, thereby declaring war against Mexico.
President James K. Polk had accused Mexican troops of having attacked Americans on U.S. soil, north of the Rio Grande. But Mexico claimed this land as its own territory and accused the American military of having invaded. Mexico was just reluctant to sell its land so there was no justification to declare war on them.