The speed of sound (344 m/s) is very less than the speed of light(3 x 108 m/s). The Sound of thunder takes more time to reach the surface of Earth as compared to light. Hence, a flash is seen before we hear a thunder.
Lightning emits a flash and thunder at the same time. Since light travels at such a rapid pace, a flash can be seen almost immediately. Thunder, on the other hand, is heard a few seconds later since
Speed of light >>>> speed of sound
The speed of sound increases as the density of the medium increases.