In April 1, 1997, Congress passed a law that punishes people for staying in the US unlawfully, without a legal status. It also includes any stay after a valid visa has expired. Per the law, people were not allowed from coming or returning to the US for three or ten years depending on the length of their illegal stay in the US. These bars are commonly referred to as three and ten-year bars. These temporary bars are for people who are abroad and trying to return to the US, not for people who are already in the US who qualify to apply for permanent residence (green card) here.
Persons who have spent more than 180 continuous days in the US illegally are barred from coming to the US for three years. Persons who spent more than one continuous year in the US unlawfully can be barred from coming back to the US for ten years. Persons who stayed in the US illegally but now have married a US citizen or permanent resident can apply for waiver and the time bar may not apply for such persons.
Persons who married a US citizen (not a green card holder) can also adjust status from undocumented to conditional residency, regardless of how long they stayed in the US illegally as long as they entered the US legally.
Some persons who seriously violated immigration laws can be permanently barred from immigrating to the US. People who spent a total of one years unlawful time in the US or are ordered deported can be barred permanently. When such persons leave and return or attempt to return to the US illegally without a visa or other valid permission, they are permanently inadmissible to the US.
If the person does not come back illegally, he/she would be subject to the 10 year bar as their illegal stay was for more than a year. But when that person ignores this and attempts to come back illegally, that is when this permanent bar applies. It is a very strict aspect of immigration law and there is no way out of this permanent bar. Persons who are subject to permanent bar cannot adjust status even if they get married to a US citizen. It is clear that you will not be punished as long as you enter legally, overstay and marry a US citizen without leaving the country. So overstaying is not considered a big mistake as long as you get married to a US citizen.