In a balloon, we have high pressure air. When it is popped, this air inside escapes and expands in a very short time. This sudden expansion of air produces a sudden sound wave, which we hear as a loud sound.
During lightning, similar phenomenon happens. When lightning occurs, charge moves from one cloud to another. During this, huge amount of heat is produced. This heat causes a sudden expansion of surrounding air, as air expands on heating. During this expansion, a sound wave is produced, and this is heard as loud sound-thunder.