The answer lies in the concept of quantum mechanics. Every single electron of an atom has its own unique set of quantum numbers. It is stated in the Pauli Exclusion principle that no two electrons would have the same quantum numbers. That is why each electron occupies a specific orbital. In addition to the Pauli Exclusion Principle, the other laws and principles that help set the quantum numbers are the Aufbau Principle and the Hund's rule.