I don't understand why this circuit works with MOSFET
When IN1 = 0, current flows from +24V through R5 then R9 then through Q5's body diode to ground. That makes the divider R5 and R8 have a voltage of \$\frac{24V - V_d}{2} \approx ~12V\$. See that little diode in the MOSFET symbol? It's not there for no reason. Almost all discrete MOSFETs have that.