According to quantum mechanics, energy level of electrons in an atom only depend on principal quantum number, $n$.
This is only true for Hydrogen, and only for the gross structure. Based on your picture, it looks like you're talking about Sodium.
Disclaimer: this is a really long answer.
In non-Hydrogenic systems, (that is, multi-electron atoms), you're not just considering interaction between one electron and the nucleus - you also need to account for the repulsion between the other electrons. The full Hamiltonian of an $N$-electron system (neglecting further corrections like fine structure, which is responsible for the splitting between the $^3P_{3/2}$ and $^3P_{1/2}$ levels in your diagram) is
$$ H = \sum\limits_{i=1}^N \left( \frac{-\hbar^2}{2m_e} \nabla_i^2 - \frac{Z e^2}{4\pi\epsilon_0 r_i} \right) + \sum\limits_{j>i} \frac{e^2}{4\pi\epsilon_0 r_{ij}}.$$
The first term in this expression is the kinetic energy of each electron, the second is the potential energy of each electron due to the nucleus, and the third is the electron-electron interaction. So we can write the Hamiltonian in short-hand as $H = K + V_{nuclear} + V_{electronic}$.
In order to do perturbation theory with this Hamiltonian, we wish to write it in the form $H = H_0 + H_1$, where $H_1 \ll H_0$. A first guess would be to use the (separable) first two terms as $H_0$, but the electron-electron interaction is too big to be treated as a perturbation. There are around the same number of electrons as there are protons in the nucleus $(N \approx Z)$, and the distance scales are around the same $(r_{ij} \approx r_i)$, so the magnitude of the electron-electron repulsion is around the same as the nuclear attraction. So we can't use perturbation theory with the Hamiltonian in its current form.
We make progress through the observation that closed shells of electrons are spherically symmetric. This means that, even though the electronic potential is large, most of it is spherically symmetric. We make the central field approximation and absorb as much as possible of the electron-electron term into the spherically symmetric term:
$$H = H_0 + H_{re}$$
where
$$H_0 = \sum\limits_{i=1}^N \left( \frac{-\hbar^2}{2m_e} \nabla_i^2 + U(r_i) \right)$$
$$H_{re} = \sum\limits_{i=1}^N \left( - \frac{Z e^2}{4\pi\epsilon_0 r_i} - U(r_i) \right) + \sum\limits_{j>i} \frac{e^2}{4\pi\epsilon_0 r_{ij}}.$$
Here $U(r)$ is known as the central potential, and $H_{re}$ is the residual electrostatic interaction. All that has happened in this step is that we have added-and-subtracted $U(r_i)$ to the right hand side, but with a careful choice of $U(r)$, we can ensure $H_{re} \ll H_0$. Hereafter we will talk exclusively about the central potential - $H_{re}$ is interesting, but not relevant to what we're talking about right now.
The key to understanding the lifting of the $l$-degeneracy is understanding the form of the central potential. We can use computers to deduce a precise numerical form for $U(r)$, but it's not as important as a basic physical understanding of its behaviour.
Consider screening of a single valence electron in an atom with closed inner shells of electrons. Since the inner shells are spherically symmetric, the valence electron experiences an entirely spherically symmetric potential $(H_{re}=0)$. When the valence electron is far from the nucleus, Gauss's law tells us that the charge of the inner electrons 'cancels out' most of the nuclear charge, and the potential is a Coulomb potential due to a charge $+e$ (since there are $Z-1$ electrons doing the screening). Conversely, when the valence electron is near the nucleus, it is 'inside' the other electrons and sees the Coulomb potential of the full nuclear charge $+Ze$.
This argument tells us that far from the nucleus, the potential tends towards a $-1/r$ proportionality. Near the nucleus, the potential tends towards a $-Z/r$ proportionality. We may write it in terms of an effective nuclear charge $Z_{eff}(r)$:
$$U(r) = \frac{-Z_{eff}(r) e^2}{4\pi\epsilon_0 r},$$
where $Z_{eff}(r)$ tends to 1 at large $r$, and $Z$ at small $r$.
Please excuse my poorly drawn and photographed sketches of $U(r)$ and $Z_{eff}(r)$: 
So the potential felt by the valence electrons departs from the $1/r$ dependency seen in Hydrogen. This is what lifts the degeneracy between states of different $l$. The potential near the nucleus is 'lower down' than in a Hydrogenic $1/r$ system, so states that are localised near the nucleus are lower in energy than they would be in Hydrogen. Since the states of lower angular momentum (like $s$-states) are nearer the nucleus, these are lower in energy. There is a small subtlety here: in Hydrogen, this effect is exactly cancelled by the kinetic energy of the higher-AM state, but this doesn't apply in non-$1/r$ potentials.
Tl,dr: atoms with more than one electron are not degenerate in $l$, due to the departure of the central potential from the Hydrogenic $1/r$ potential.