Electricity is mostly generated one way.
You turn a crank. Turning the crank is hard (it doesn’t spin freely). It costs energy to turn the crank. Some of the energy spent turning the crank is turned into electricity using magnets and stuff (off topic here).
Question is: how do you turn the crank? Hint: turning it by hand is way too hard.
Wind: you attach the crank to a windmill, and have the wind turn the crank for you.
Water: you attache the crank to a water wheel, and put the water wheel in a water flow. This works poorly. What works better is to build a dam to raise the water lever, then have a pipe running from the top of the dam to the bottom. That pipe will have high pressure water running down it. You put your waterwheel inside that tube. Turns the crank real hard.
Coal: You boil water with some coal. Run the high pressure steam into a pipe. Have a turbine in there (like a windmill, but for pipes. It turns if you blow on it). Attach the crank to the turbine.
You don’t need to use coal to heat up water. It works equally well with natural gas, oil, or a controlled nuclear reaction. Oil, gas and nuclear are just the fuel to boil the water.
Geothermal? You use magma to boil the water. Then, pipe, turbine, crank.
The lights on my bike? The dynamo is just a crank that my wheel rubs against and it forces it to turn.
(Photovoltaic is different. It does quantum shit with electrons. It’s like Power Production 2000. Everything else is totally steampunk).
The reason why we use so many ways to turn a crank is that, some places have a damable river. Some places have a lot of wind. Sometimes you have easy and cheap access to coal and to hell with the poisonous smoke. Sometimes you feel a bit insecure if the entire power production of your nation depends on another country being friendly with you and selling you one fuel or another, so you diversify. Sometimes you need a source of radioactive material to build doomsday devices (Hi France, hi Iran)… So we use plenty of ways to turn that crank and force the magnets to do their things. But it’s all crank-turning really. Except for solar.
Latest Answers