The key difference between an explosion and a combustion is speed not energy produced
The key thing that matters for explosives is how fast the reaction proceeds. TNT detonates, which means that, in solid TNT, the reaction propagates through the solid faster than the speed of sound. Some slightly gentler explosives (like the propellants used for bullets and shells) also have fast propagation but slower than the speed of sound: they are said to deflagrate. In both cases the distinguishing feature is how fast they release their energy.
Explosives can do this because they involve reactions that don't need external substances to complete the chemical reaction involved in the process. They usually contain large amounts of oxygen and nitrogen in their molecular structure (which tend to lead to products containing nitrogen gas, nitrogen oxides, carbon dioxide and so on).
Coal burns slowly. It only burns when oxygen can get at the coal's surface. And coal, being a not very porous solid, doesn't make this easy for the oxygen. So the reaction might release more energy but the speed is limited to perhaps mm/min by the physical structure.
But not always. if coal dust (or indeed any other dust of a flammable material) is dispersed in air, the speed of oxygen diffusion is no longer a limiting factor. This is why dust explosions are very dangerous (and not just for coal: the commonest are in flour mills and grain silos). Coal dust in those conditions can detonate and release catastrophic amounts of energy very quickly.
It is also worth noting that the largest known non-nuclear bombs used by the military are based on a similar principle. Thermobaric bombs involve dispersion of some fuel (like a liquid hydrocarbon with even more combustion energy than coal) to a fairly precise level in air where the resulting mixture will explode rather than combust. This is not the usual behaviour for combustible fuels like gasoline as getting an explosive mixture in air rather than one that will just burn is not easy (which is why the every-car-crash-explodes movie trope is nonsense). So getting the right mix of fuel and air can yield a very big explosion even more effective than TNT.
in short, to understand explosions you need to think kinetics not just thermodynamics of the underlying reactions.