Actually, hydroelectric and coal-fired power plants produce electricity in a similar way. In both cases a power source is used to turn a propeller-like piece called a turbine, which then turns a metal shaft in an electric generator , which is the motor that produces electricity. The results are the same. The dam stores lots of water behind it in the reservoir. Near the bottom of the dam wall there is the water intake.
Gravity causes it to fall through the penstock inside the dam.
At the end of the penstock there is a turbine propeller, which is turned by the moving water. The shaft from the turbine goes up into the generator, which produces the power. Power lines are connected to the generator that carry electricity to your home and mine. The water continues past the propeller through the tailrace into the river past the dam.