The history of the success of defensive walls in general is a dubious one. The Great Wall of China did not ultimately protect China from its northern neighbors, such that the final Imperial Dynasty wasn’t Chinese at all.
Even other somewhat less ambitious walls like Hadrian’s Wall or Offa’s Dyke had only limited success. I guess probably the most successful was the Berlin Wall, but there were enough porous borders between the Warsaw Pact and the West that the Berlin Wall was more a symbol than an effective means of containing and protecting Eastern Europe.
The better solution is to work to make Mexico an economic success, to find ways to help it deal with systemic corruption and crime, thus giving Mexicans no particular reason to even want to cross the border. It has worked fairly well along the US’s northern border. It’s not as if there are millions of Canadians trying to get into the US, and that’s because Canada’s standard of living and general economic conditions are close enough to the US’s that it’s hard to imagine any large number of Canadians trying to sneak across the border. Your basically left with smuggling as the primary reason anyone tries to get across the US-Canada border illicitly.