These are the electrons that can rearrange in chemical reactions. The other ones are more strongly bonded to the nuclei and stay where they are. More in detail, rearranging these would cost energy and doesn't happen (in a first analysis).
Then, you have all added subtleties of almost-outer electrons that can react too. It's the case in carbon for instance, where the 2s electrons are the shallowest (and carbon does show the valence 2) but the 2p, a bit deeper in energy, often react too (so carbon often has the valence 4).
It gets more fuzzy with transition elements where many orbitals are shallow, so they can fill more or less and in a varying sequence. Such elements show a broad set of valences and often serve as catalysts as they can pick or release a molecule fragment just by changing their oxidation state.