The 3rd and 4th energy levels are so close that they overlap. This is because as the orbitals get further from the nucleus, the distance between them decreases. The 4s subshell therefore sits closer to the nucleus. Hence, it takes less energy to fill the 4s subshell so it is filled first and then electrons are added to the 3d subshell.