Bands bend as charge carriers move from one material to the other, and this puts charges in the materials near the contact. A bit lengthy, and the situation depends on individual cases. There
https://en.wikipedia.org/wiki/Band_bendinglinks to other articles.
Beware that the usual theories work badly (or not at all...) on metal-semiconductor contacts, which tend to be dominated by the interface's properties. Contact potentials are not the predicted ones, you can get Schottky contacts where ohmic ones are expected or the other way. Serious mess.
What's the relationship with the thread's title, "electrochemical water splitting"?