Some replies already, but just to add (sorry, train nerd here).. It's not for a lot of locomotives, but virtually all locomotives. Early diesel locomotives tried to use a mechanical transmission but this mostly failed because you can't scale the technology up well, and this is my own speculation but I think you need to be able to shift under full load
. The transition from steam didn't happen until diesel-electric was invented. This combination is also good for reducing wear on brakes, as you can use the motor as a generator and resistors to dissipate power as heat. I don't know of a locomotive that uses regenerative braking, but it's used on some passenger trains in Japan. Not by storing energy in batteries, but by feeding into the local power grid!Diesel-hydraulic was also tried for a while but was largely unsuccessful. For special applications, like maintenance equipment or moving things in a railyard, you can still find some diesel-mechanical and diesel-hydraulic equipment.
If a freight train stops, depending on its length, it must reverse to add slack between cars. Then it starts by effectively pulling each car one by one. You can hear it as a bang-bang-bang if you're nearby, depending on the coupling method between cars. If a train loses momentum on a hill, it may have to reverse and start from the bottom.