Quick Answer: A ground-fault circuit interrupter (GFCI) compares the current going out to an appliance on the hot wire with the current returning on the neutral wire. If the difference is large enough, the GFCI trips and cuts power to the appliance. (OSHA 3075, page 14)

Where can the missing current go?

Think of a washing machine spinning a load of towels. The motor uses electrical energy to turn the drum. Even when the motor is working hard, just as much current normally comes back on the neutral wire as goes out on the hot wire.

Now suppose a live wire inside the washer rubs against its grounded metal case until the insulation wears through. Some current can then flow through the case and back to the source along the machine’s grounding wire. That share bypasses the neutral wire, so the outlet can sense the imbalance even though the fault is inside the washer.

If current flows through a person and all of it returns on the neutral wire, the GFCI senses no imbalance. That’s why a GFCI may not protect someone who touches the hot and neutral wires at the same time. (OSHA Construction eTool)

Sources & further reading

That’s the mechanism. The wonder is still allowed.