Spain, too, has former colonial possessions on the North African coast, Ceuta and Melilla, ever heard of them? They both have walls...
They are not former colonial possessions btw, they are way precolonial possessions. Pre Spain in fact.
About the walls, they are financed by Spain and the EU under the european exterior borders program, the razor wire was retired some years ago for humanitarian reasons but height has been risen to six meters.
Leaving aside political, moral o legal considerations, consider this:
The walls are both about ten km long only, ten kms packed with surveillance systems, police, dogs and such. And every year a lot of immigrants jump it successfully. A similar wall all along mexican border would be pharaonically expensive, it might prevent some immigrants of entering, sure, mostly women and children, but not all, and would not stop the bad hombres, or weapons or drug traffic.