Electrons occupy orbitals of the lowest energy available.
No two electrons in the same atom may have all four quantum numbers alike. This means there are the maximum of 2 electrons in one orbital.
In a group of orbitals of identical energy i.e. in the same subshell, electrons enter empty orbitals whenever possible. Electrons in half-filled orbitals have parallel spins