Thermodynamics, specifically the Carnot Cycle.
Heat engines do turn heat into mechanical energy (motion).
What they don't do is do this with infinite efficiency.
In practice, Carnot engines (heat engines) tend to operate at efficiencies between about 20 to 50%, with an average close to 30% percent. This means that most thermal electrical generation produces roughly three times as much heat as it does electricity. This applies across thermal mechanisms: diesel generators, gas turbines, coal-fired steam, and nuclear-powered steam plants.
There's some room for increased efficiencies, and multi-pass systems, or systems with incorporated thermal applications (district space heat, industrial heat, food preparation) can achieve higher net efficiencies, though I believe the peak is around 60%, and that is rarely achieved.
The other parts of the generating cycle are far more efficient. Generators typically operate well above 90% efficiency (mechanical energy in to electrical energy out), and distribution typically sees about 6% losses.
But that first thermal step costs a lot. There's no such thing as a free lunch.
Wouldn’t a Carnot engine with 33% efficiency produce 2 J of heat per 1 J of mechanical work? With 40% efficiency 1.5 J of heat? Efficiency of the generator should be better than 90 % so I think the 3x estimate is a bit off.