You understand that changing the law to allow people who broke into our country illegally to reenter without penalty is making them “legal”.
Congress could make them all legal overnight - by simply changing the law. So “legally” is whatever you make the law and not all that meaningful after the fact.
Work visas are not amnesty and doesn’t legalize them. But they enter the country legally.