In the beginning of household electricity, there were no appliances, and therefore no plugs and sockets for appliances. The early use of electricity in the home was for lighting, so there were sockets for light bulbs.
Enter the appliance. Where can it be plugged in? The only place is a light socket, and the first appliance plugs looked like light bulb bases. Very soon, easier-to-use plugs and sockets developed, with the sockets designed to screw into light fittings as adapters. For example, for a light fitting of Edison screw type: https://commons.wikimedia.org/wiki/File:Gluehlampe_01_KMJ.jpg an adapter with a similar screw fitting would be installed in the light fitting: https://commons.wikimedia.org/wiki/File:Light_socket_plug_adapter.jpg
Different manufacturers designed different plug/socket systems, often making them deliberately incompatible. While this had advantages for the manufactures, it had many disadvantages for consumers, which only increased when permanently wired sockets came into use. The answer: standardisation, where governments decreed what sockets could be used. Different sockets being in most common use in different places before standardisation often dictated what standard was adopted, and thus standards varied. Thus, we see 3 major groups of 220-240V plug types (the two round pin European type, the British G type, and the angled pin I type (Australia, China, and some other countries; this was originally a British type, but has become extinct in its country of origin)).
There are some good reasons to retain multiple types of plugs/sockets. In particular, different voltages are used in different countries (e.g., 110V, 220V), and having different standard plugs prevents accidentally plugging an appliance into a socket with the wrong voltage. For example, type A/B plugs are used in most countries with 110-120V power, and in very few countries with 220-240V power. In cases where buildings include DC wiring, it is wise to use different plugs/sockets from those used for the AC supply.
For the early history, see Fred E. H. Schroeder. (1986). More "Small Things Forgotten": Domestic Electrical Plugs and Receptacles, 1881-1931. Technology and Culture, 27(3), 525-543. doi:10.2307/3105384
For modern types by country: https://www.worldstandards.eu/electricity/plug-voltage-by-country/