The US situation is more nuanced than you're framing it as. Even in Mexico there's largely negative sentiment against illegal immigration, as they also suffer from it with the caravans composed primarily of large numbers of young unattached males from a mish mash of places in South America pass through Mexico. They don't tend to leave happiness in their wake. The majority of Mexicans (55%) want them forcibly deported with a slightly smaller majority (51%) of supporting using the National Guard to carry out and enforce such deportations. [1]
Nobody knows exactly how many have come over, but there are estimated to be around 15 million illegal immigrants in the US, primarily via the southern border. For scale, the largest city in the US is NYC with about 8.5 million people. The 10th largest is Fort Worth, Texas with about 1 million. And that's after multiple waves of amnesty legalized millions more, which obviously did nothing but further incentivize more illegal immigration, exactly as in Spain.
[1] - https://www.washingtonpost.com/world/the_americas/unauthoriz...
[1] - https://archive.is/KruVX
So the question becomes, since Mexico is really really huge, why doesn’t the Mexican governemt do anything about these caravans? Not to mention that Mexico is pretty narrow at its southern end.