Those areas were a part of Mexico for 25 years. That’s when Mexico officially became Mexico just about 200 years ago. Spain left giving the land to Mexico, but the U S contested it.
It wasn’t a long term national holding going back hundreds or thousands of years. The local Native Americans owned the land. Mexico didn’t.
I believe Mexico was formed around 1825. The US went to war with Mexico.
We defeated it and the paid for the land. This was around 1850.
There was a secondary land purchase a few years later and the border was set.
Those that say we stole Mexico’s land don’t understand the history of the region.