Odd 74HCT1G125 behaviour
You aren't allowed to put more than VCC+0.5V on the output pin, even if it's in high-Z state. If you do, you could damage the chip.



What's happening in your circuit is there's a diode connected from the output pin to VCC, oriented so that it will be reverse biased in normal operation (cathode connected to VCC). This diode is there to shunt current during ESD events.

When you connect 12 V to the output pin, you forward bias this diode and deliver current out of the VCC pin. Depending what else is connected to the same VCC net, you could damage those other parts, or high current through the ESD diode could damage the 1G125.