Lightning and thunder are produced by the same event, but they reach you at very different speeds.
The flash travels as light.
The thunder travels as sound.
Light moves so much faster through air that, for ordinary storm distances, the flash reaches your eyes almost immediately while the sound may take several seconds to arrive.
Lightning creates thunder
A lightning channel heats the surrounding air extremely quickly.
That rapid heating causes the air to expand violently. The sudden expansion launches a pressure wave through the atmosphere.
That pressure wave is thunder.
So lightning and thunder are not separate weather events that happen one after the other. They are closely connected parts of the same event.
Light is much faster than sound
Light travels at roughly 186,000 miles per second in a vacuum and nearly that fast through air.
Sound through ordinary air moves at only about 1,100 feet per second, although the exact speed changes somewhat with temperature and other conditions.
That difference is enormous.
If lightning happens several miles away, the light covers the distance in a tiny fraction of a second. Sound needs several seconds.
Can you estimate how far away lightning is?
Yes, roughly.
Count the seconds between seeing the flash and hearing the thunder. Dividing that number by about five gives a rough distance in miles.
If the thunder arrives about ten seconds after the flash, the lightning was roughly two miles away.
This is only an estimate because sound speed varies and a lightning channel can stretch across a large area.
Why does the delay change during a storm?
As a storm moves closer or farther away, the sound has a different distance to travel.
Nearby lightning may produce thunder almost immediately after the flash.
More distant lightning creates a longer delay.
You may even see lightning so far away that the thunder becomes too weak to hear by the time it reaches you.
Does the flash always reach you first?
For normal viewing distances in the atmosphere, yes.
The delay is not because your ears are slower to process sound than your eyes process light. The dominant reason is simply the enormous difference in travel speed.
Why does nearby thunder sound sharper?
When lightning is close, many parts of the sound reach you in a shorter window of time, so thunder can sound like a sharp crack or bang.
Farther away, different portions of the lightning channel arrive at different times and the sound can become a long rumble.
So the storm is not politely showing you the lightning before playing the sound effect.
The two signals started nearly together.
Light just won by an absurd margin.
A related part of the natural world appears in Why does thunder rumble?, where the same kind of physical or biological reasoning answers another familiar question.
And that’s the short explanation.
Related explanations: Why does thunder rumble?, Why does rain smell so good?, and Why do shadows change size?