The time between lightning and thunder occurs because sound waves travel much slower than light waves.
We see the light of the lightning immediately (the speed of light is 300,000 km per second).
The sound waves, on the other hand, need about 3 seconds per kilometer.