A U.S. citizen is allowed to marry an illegal alien. This does not grant the immigrant citizenship and does not protect the illegal person from deportation. It helps with expediting green card submission in some cases but still requires the illegal immigrant leave the country to do so.
Illegal immigrants are able to marry American citizens but do not earn citizenship by doing so. Anyone in the United States without express legal permission, such as individuals who cross borders without passports, visas or green cards, are considered to be in the country illegally. Others who have these documents but allow them to expire also are deemed to be in the U.S. without legal right to maintain that status.
People who marry American citizens while holding an illegal immigration status are still required to file for citizenship status. They are subject to deportation and criminal prosecution for being in the country illegally. Filing for citizenship is often expedited once a marriage is finalized but the illegal immigrant is still liable to be deported before applying for that status. Fines and penalties are often weighed against the American citizen as well for aiding and abetting a criminal and for trying to enter into a contract with an individual who is not entitled to be in the country.