The US did offer to buy the territories, Mexico said no, then the US invaded and took them. During the peace process after the war, the US then paid less than half of the initial offer for the territories that it was never going to give back.
Later, the US bought a sliver of land on the border for a slightly inflated price, but that was its own thing.
But you can't really call an armed invasion, and then a pittance paid out in damages, to be "Buying them all".
The United States could have just taken all of Mexico, but it didn't. It paid for the land. The population of the western states was made up of Americans anyhow, less than a thousand Mexican citizens lived in those areas at the time.
It was okay to launch a war of conquest because the Mexican government was weak?
All because a bunch of American slave owners invaded Texas and started a war of "independence".
But there's more to the story. Mostly Santa Anna. He became a national hero for beating back attempts at conquest by both Spain and France. He became president and then sparked a multi-front civil war by centralizing power in his own hands...
The US took most of the land from Mexico that was worth taking. There's little viable agricultural land south of Texas. Also, it put a lot of land in between Mexico and New Orleans, which is an incredibly important international port. With that secured, no foreign army would be able to threaten that port without major logistics challenges, much less fighting through the US Army and every local citizen with a gun.
The US grabbed what it wanted and let Mexico keep the scraps.
That is looking at it from today, not from how it was viewed then. The main reason Mexico was fine with selling was the massive desert that separated the two areas and the extremely violent native population that inhabited the region. That reason didn't become peaceful until the 1920s.
Spain was loosing influence in the Philippines at that time so to cut their loses they offered the Philippines to the US. They even fought a mock battle where Spain "lost".