Simulation showing different results for a same practical case
The voltage at GPIO pin @ both the cases are the same 12V

No it isn't, in the second case the voltage is 5.7V.
The important thing to understand about resistance dividers is that they are not voltage regulators; with nothing else connected you achieve a specific voltage. When you connect something which draws current from the middle, then the current in the resistors is now different, and as a result they take on different voltage values.
It may become clearer if you try, for example:

measure the current at various points in the circuit. What current is travelling through each resistor? What current is through the diode?

putting a 1 ohm resistor between the &quot;direct&quot; supply and the pin. Vary this upwards - try 100R and 1K. This will reduce the voltage at the pin without explicitly having a resistor divider; the diode is effectively acting as the other &quot;leg&quot; of the divider.