There is a real reason, and the pull cord is the clue that ties it together: it is about keeping mains voltage away from wet hands.
European wiring rules divide a bathroom into zones measured from the bath or shower, and each zone limits what may be installed in it. Ordinary switches and sockets are restricted in the zones nearest the water. A small bathroom can easily be almost entirely inside a restricted zone, at which point there is nowhere compliant to put a switch.
That leaves two compliant options, and you have seen both:
- Put the switch outside the door.
- Use a pull cord, where the only thing your wet hand touches is an insulating string and the switch mechanism itself sits in the ceiling, well away from everything.
Countries where the switch is inside the bathroom generally have rules written around a different assumption — usually that a residual current device on the circuit handles the risk, so the switch position matters less.