Explosive compound result from 3 major sources of potential energy, and I am aware some compounds do not fit in these categories nicely, such as metal acetylides.
Ring strain/cage strain: ex octanitrocubane, trinitroazetidine , HNIW
Carbon backbone oxidation: traditional stuff like RDX, TNT
highly positive heats of formation.azotetrazolates, nitrotetrazoles and other high-nitrogen heterocycles.
Basically you are creating a metastable compound, the products of decomposition(in this case, detonation) are of much lower potential energy than the explosive, so the explosion process releases a lot of energy at once.
Detonation only refers to when the decomposition of a material takes place at a speed faster than the speed of sound in that material.
Why this leads to explosion is you initially have lets say, 1.5g of say, free nitrotetrazole, So HCN5O2. Say to make the math easy it has a density of 1.5g/cm3 (a reasonable density). This detonates releasing gaseous water, carbon monoxide/dioxide and nitrogen. By conservation of mass, this 1.5g of gasses are initially confined to the 1mL originally occupied by the explosive. I can let you do the math to calculate the pressure, but suffice to say, its really really above STP, so they expand, and they do so really dang fast. This causes the explosion effect.
For example detonation pressures above 20 Gigapascals are common for explosive materials.
Also, pure sodium in pure chlorine is pretty energetic even with low surface area sodium....
The term volatile to describe a reaction is useless. Volatile refers to the vapour pressure of a material.