(a) Deep in each region the material is neutral, so the potential is constant there. Across the depletion region it rises smoothly from the p-side value to the n-side value, by the barrier potential V0.

(b) The n-side is at the higher potential. When the junction forms, electrons diffuse from the n-side to the p-side and holes from the p-side to the n-side. The n-side near the junction is left with uncovered positive donor ions, and the p-side with uncovered negative acceptor ions. A layer of positive charge on the n-side and negative charge on the p-side makes the n-side positive relative to the p-side, by V0.
The field points from the positive charge to the negative charge, so in the depletion region it points from the n-side to the p-side. This field opposes the further diffusion of majority carriers.