Thunder and lightning storms occur when warm, moist air rises quickly to form cumulonimbus clouds. The air and water in these clouds start rubbing against each other. This builds up electricity between the cloud and the ground, eventually resulting in a flash of lightning.
Thunder occurs when energy from lightning heats and rapidly expands the air. The resulting sound wave gets heard as thunder. While lightning and thunder occur at roughly the same time, lightning travels at the speed of light, or at 186,000 miles a second, while thunder travels at the speed of sound, equivalent to one-fifth of a mile in one second. People see the lightning long before they hear the thunder.
To determine the proximity of storm, count the seconds between the lightning flash and the thunder, then divide the number by five. The resulting number equals the distance in miles from the lightning strike. Lightning striking close by results in a loud, short bang of thunder, while lightning farther away produces long, low rumbles of thunder.
Lightning occurs in thunderstorms and hurricanes, volcanic eruptions and even in heavy snowstorms. Lightning also shows up in extremely intense forest fires and surface nuclear detonations. The first bolt heads downward, completing the circuit between the cloud and the ground. The second bolt occurs a split second later by going back up the same path.
Source: https://en.wikipedia.org/wiki/Thunder
https://en.wikipedia.org/wiki/Lightning