I understand that electrons diffuse from the N to the P region due to the concentration difference. This diffusion of electrons creates an electric field opposing further diffusion.
What I don't understand is why diffused electrons form a layer? Shouldn't they be spread across the whole P-region?
If I assume it's because of electrical stability of the recombined atoms, it still should spread, as neighbouring atoms should also have the same level of stability.