The diode only allows current to flow in one direction, as indicated by the triangle/arrow. In this case +ve (conventional) current can only flow to the right through the diode.
When the voltage at the left of the diode is less than 5V, +ve current cannot flow towards the left from the higher voltage, because it cannot flow against the arrow marked in the diode. But when the voltage to the left of the diode is greater than 5V then +ve current can flow to the right through the diode, in the direction of the arrow. The diode then acts like a short circuit wire with no resistance.
This prevents the voltage at the left side of the diode from becoming larger than 5V at any time.