Auto transfer switchs work 2 ways.
Some sit open, connected to nothing. When shore power is applied, it closes, completing the circuit. When generator power is sensed, it switchs to that, as generator power is the priority position.
Others sit connected to shore power and plugging in just sends the power thru. As above, they will switch to generator if it is producing power, regardless of shore power being on or off.
With both, If you shut off the generator, while the shore power is still connected, it switchs back to that.