The orbital (electron) energy is basically determined by the energy of attraction between an electron in the orbital and the nuclear core charge. In a multi-electronic atom, the effective core charge felt by an electron is influenced by other electrons in the system, particularly those that are closer to the nucleus. There is also an effect called "orbital penetration", which is more pronounced for some types of orbitals than others. For the same principle quantum number, n, S orbitals have more electron density close to the nucleus than P (or D or F) orbitals, an effect that arises from the quantum mechanical (wavefunction) treatment of electrons. Because S orbitals "penetrate" closer to the nucleus than P or D or F orbitals, they feel less shielding of the nuclear core charge by inner electrons, and thus have lower energy. This explains the "fill order" of orbitals in multielectronic systems. In a hydrogenic atom, there is only one electron, so the penetration effect doesn't matter.
https://www.youtube.com/watch?v=VWza-PlQTaU