Why do atoms on the periodic table have the number of valence electrons that they do?
Atoms have protons (and neutrons) in the nucleus that define the element. For example, Fluorine always nine protons. The number of electrons must balance the number of protons in the atomic state. If fluorine had ten electrons, i.e. a full inner and outer shell, it would be a negative ion with net charge -1, so the electrostatic charge would repel the last electron.
It is only with the help of other atoms nearby that charges can be (almost) balanced. In $\ce{LiF}$, the fairly positively charged $\ce{Li+}$ ion attracts the comparatively negatively charged $\ce{F-}$ ion, so there is no net unbalance in a crystal of $\ce{LiF}$, though in each pair, the valence electron spends most time in the outer shell of fluorine.