Nearly all fossil-fuel burning train engines (I think the exception being a handful of hydraulic engines in Germany?) are diesel-electric, which use the diesel engine to turn an electric generator to power electric traction motors. (Dynamic breaking is when those traction motors are used as generators, but that electricity is usually dissipated as heat immediatly.)