Why do we sometimes hear thunder long after seeing lightning?
Lightning heats the surrounding air extremely quickly, causing it to expand and produce the sound we call thunder. Light travels much faster than sound, so the flash reaches your eyes before the thunder reaches your ears. A longer delay generally means the lightning was farther away.
As a rough estimate, divide the delay in seconds by three to get the distance in kilometres. Do not use this as a reason to remain outside: if you hear thunder, seek shelter in a substantial building or enclosed vehicle. Avoid open areas, isolated trees and water during a thunderstorm.
Source: US National Weather Service: Thunder