when any electricity leaks out (for example through your body) it switches off. the eu also has the same system, but its one switch for your entire house. the us also has this but only in bathrooms.
They're connected to an RCD, as modern UK wiring has all sockets connected via an overall RCD in the fusebox, but the switches on the socket are just basic on/off switches.