The Fermi level is the energy separating occupied states of the valence band from empty states of the conduction band at the absolute temperature T=0 Kelvin. In an intrinsic semiconductor, when we follow the band-symmetry approximation, which assumes that there are equal number of states in equal-sized energy bands at the edges of the conduction and valence bands, i.e. n = p implies that there is an equal chance of finding an electron at the conduction band edge as there is of finding a hole at the valence band edge. So we observe the Fermi level in the middle of the bandgap.
For a p-type semiconductor, there are more holes in the valence band than there are electrons in the conduction band i.e. n < p. This implies that the probability of finding an electron near the conduction band edge is smaller than the probability of finding a hole at the valence band edge. Therefore, the Fermi level is closer to the valence band in a p-type semiconductor.
On the other hand in case of n-type semiconductor it will shift towards conduction band.
So you can say shifting of the Fermi level in extrinsic semiconductor from the equilibrium Fermi level is only the explanation of probability of finding the maximum dominant carriers of the type
Source: www.researchgate.net
np-type semiconductors
Mod-01 Lec-07 Extrinsic semiconductors - Fermi level
Fermi Level in Extrinsic Semiconductor - Theory & effect ...