They did not sell most of the land to us. We acquired over 500,000 square miles of Mexican territory by aggressive warfare. Google “Treaty of Guadalupe Hidalgo” and read a few articles. Here is one I found interesting: https://www.mtholyoke.edu/~jasingle/conclus.html
Only the Gadsden Purchase was a negotiated sale. It was just under 30,000 square miles and served several useful purposes as described here: https://en.wikipedia.org/wiki/Gadsden_Purchase
With the defeat of its army and the fall of its capital, Mexico entered into negotiations to end the war. The treaty called for the U.S. to pay $15 million to Mexico and to pay off the claims of American citizens against Mexico up to $3.25 million. It gave the United States the Rio Grande as a boundary for Texas, and gave the U.S. ownership of California and a large area comprising roughly half of New Mexico, most of Arizona, Nevada, and Utah, and parts of Wyoming and Colorado. Mexicans in those annexed areas had the choice of relocating to within Mexico’s new boundaries or receiving American citizenship with full civil rights. Over 90% chose to become U.S. citizens.
https://en.wikipedia.org/wiki/Treaty_of_Guadalupe_Hidalgo