It’s quite simple, because of cheap labor and lack of worker protections, Mexican workers produce goods more cheaply than US workers. Because of NAFTA, American companies can outsource production to cheap Mexican labor. This has the effect of A) screwing up the Mexican economy because they are all production and no consumption. B) making Mexican workers want to work in the US for higher wages, C) screwing up the US economy because we don’t produce anything, so immigrants have nowhere to work when they get here.
Obvious solution - penalties on companies for outsourcing labor, making it economical to produce domestically, which is what NAFTA eliminated.