Each box is one orbital, and each holds at most two electrons, one spinning each way. That limit is the Pauli exclusion principle. Electrons fill the lowest-energy boxes first, one per box before any pair up, so each new element adds one electron to the next free place. The count in the outermost shell, on the right, sets how an element behaves: neon's outer shell is full and it reacts with nothing, while sodium's single outer electron is easily given away.