Different shells can hold different maximum numbers of electrons. Electrons occupy shells starting with the innermost one. They begin to occupy the next shell when a shell becomes full.
The ions formed have a full outer electron shell, so are very stable. See the study guide on groups in the periodic table for more information.