Countries use different plug shapes mostly because electrical standards developed separately in different places and were never unified. Plug designs (types A through N, for example) vary in pin count, pin shape, and whether they include a grounding pin, and many regions adopted their own standard as early electrification spread.
Differences in plugs also reflect differences in voltage and frequency, such as 120 V at 60 Hz in North America versus 230 V at 50 Hz across much of Europe and Asia. Travel adapters only change the plug shape, so they cannot convert voltage, which is why some devices need a separate transformer.