Yeah, and that does suck for those people. They do it by the book and a bunch of people who don't are not punished. Its the same thing when there is intentional inflation and monetary devaluation. Plenty of people save their money and do it right, and then here comes inflation to wipe out their savings.
When too many people break the law, sometimes the best thing to do for the country as a whole is to declare amnesty. It isn't fair, but that's best for the country. We either give them amnesty, have them apply for citizenship, and maybe make them pay a tax penalty for a few years or spend billions of dollars deporting them. I don't like either option, but the status quo isn't acceptable either.