How does diode clamp protection work?
\$V_{out}\$ is connected to the 5V supply in Figure 2. This means that the voltage at \$V_{out}\$ must be 5V.

If you are wondering why there is no conflict between \$V_{in}\$ and the 5V supply then the answer centres around \$R_2\$. If you look at the voltage across \$R_2\$ you know that \$V_{R_2}=7V\$ as there is 12V on one side and 5V on the other side. Because of Ohm's law this means that there is a current flowing through \$R_2\$. 

A current flowing through a resistor means a voltage drop, the bigger the drop is - the larger the current flowing through the resistor is (and the more energy the resistor will turn into heat as a result!).