Q1 is logically an inverter; when the input to that is high, the output is low and vice-versa.
Q2 (or a P-channel FET in that position) is working normally - and acting as another logical inverter - but itself fed with an inverted signal from Q1.
The two cascaded inversions mean the final output is in phase with the overall circuit input rather than having a single inversion as with the P-channel device within a single-supply circuit as your very first example.
Edit - if you do not want the double inversion, you can reconfigure Q1 to common base.
For that, connect the base directly to +5V and connect the emitter to the logic signal via eg. a 1K resistor.
Or use a FET with gate to +5V and source to the logic signal.
You still need the base resistors on Q2.
In that mode of operation, the transistor gives no current gain so all the current to the upper transistor base or gate is provided by the logic pin, but no current is drawn until the logic signal is low, providing base current or gate voltage to Q1.
That can only work if there is enough difference in voltage between the logic and output (Q2) supply to turn on Q2.
I can't find an appropriate logic-switch example diagram, but this shows the basic common base principle -
https://www.elprocus.com/wp-content/uploads/2017/09/2017-09-12_16-01-44.jpg
The base (or gate) is connected to a fixed voltage somewhat higher than ground, then a signal input to the emitter side is output in phase at the collector.
In your application, the 5V logic supply is the perfect base bias voltage, with the higher voltage supply (10V or more) providing the collector load supply.