Because, in the very beginning, electricity was new, and there were no standards to go by.
Every country just built it's first small power station using whatever equipment was available, and everyone had a different idea about voltage and frequency.
But once you have decided on a voltage and frequency, and you build more and bigger power stations, and start linking them together, the system grows. By that time it is not really possible to change anything.
A bit like building your very first railway. You decide on how far apart your tracks are going to be. Once you have a few hundred miles of track, and a few locomotives and rolling stock, you cannot really then decide to change the width of the tracks !!!
So countries started out (maybe over a hundred years ago) with different rail and electric power distribution systems, and cannot really ever change.