In band diagram, why the Fermi energy (EF) is constant along the device?
A gradient in the Fermi level is the driving force for carrier motion:

$$F_n = \frac{D_n}{k_BT} n \frac{\mathrm{d}E_F}{\mathrm{d}x}$$

In equilibrium (zero bias), \$F_n = 0\$ and therefore \$E_F=\text{const}\$.