Any large enough explosion will produce a mushroom cloud – but A-bomb and H-bomb explosions nearly always will owing to the size.
Essentially, the shock wave and blast effect from the explosion expands in a semicircle, the above-ground area around the explosion site, but much of the force is carried upwards. When it hits the tropopause, it begins to expand outward, producing the mushroom effect.
The explosion doesn’t even have to be large. On a calm day even a small explosion that takes place in the air produces a mushroom shaped cloud that lasts for a while.