When A is powered, why does the current go to the ground and not to Q?
For the purposes of the NOT gate, you are looking at voltage and not looking at the current. The next "logic unit" that follows will be designed to consider the voltage at OUT, not the current.
In order to consider the voltage, the next circuit will necessarily sink or source a little current (into or out of OUT.) So in reality some current also actually does get exchanged through the OUT pin. And the more logic unit inputs you tie to this output, the larger this current becomes. At some point, the circuit you show won't be able to properly do its job. So there is a limit called "fanout."
But for understanding it, you only need to realize that it is the voltage present at OUT, not the current, which defines the meaning of OUT.
The current from A only flows one direction (through the emitter to ground) because the base-emitter junction of a NPN transistor is effectively just a diode. Therefore the current cannot flow through to Q.
When current flows between the base and emitter, the transistor "switch" closes, connecting Q to ground. Effectively the transistor becomes a very low value resistor on the low side of a voltage divider (made up of the transistor and R2). When your low-side resistor in a voltage divider is a MUCH lower resistance than the high-side, then the voltage on the output (Q) is pulled very low (close to ground, or 0V).
Assuming a load with a certain impedance is connected to the output, current will flow to it whenever A is off (0V). This is because it follows the lowest impedance path. With a NPN, there will be a small amount of current flowing to the ground. With a NMOSFET, it would flow directly to the output whenever 0V are applied. If 5V are applied to the base (gate for MOSFETs), you will create a current path between collector and emitter. Thus, current will follow this low impedance path rather than going through the high impedance path which would be your load. Note that you will most likely have a small amount of current going to Q but it would depend on the load resistance and how you design your circuit.