Can a soldier in the Army marry an illegal immigrant?

Why shouldn't they be able to? And after that the immigrant becomes legal. (I think) And army people can marry can't they?