The war being referred to is the Mexican-American War (April 25, 1846 – February 2, 1848).
The roots of the conflict lay in the Texas Revolution when Anglo settlers in Mexican Texas declared their independence from Mexico, and defeated Mexican President Santa Anna's army at the Battle of the San Jacinto. Texan independence was recognised by the USA, but not by Mexico.
In 1845 U.S. congress voted to annex Texas, and President Polk demanded further Mexican territory. That led, in 1846, to the Mexican-American War. U.S. troops invaded Mexico and, within two years, captured Mexico City, effectively securing victory for the Americans.
At the end of the war, by the Treaty of Guadalupe Hidalgo (1848), Mexico was forced to cede over 55% of its territory and resources to the USA.