You may have been told as a kid during a thunderstorm that if you saw lightning and began to count "One Mississippi, two Mississippi..." however many times until you heard thunder, that whatever number you reached was the distance in miles that the thunderstorm was from you.
There is some truth to this! For every five seconds you count, the lightning strike was one mile away from you. This isn't really great at pinpointing the exact storm location, but it will give you a pretty accurate estimate on how far the most recent lightning strike is...
Example of this is you count to "10 Mississippi." With this method, you divide the 10 seconds you counted by 5 and get a distance of two miles away.
Thunder and lightning happen at the exact same time, so why do we see lightning before we hear the thunder? Well, light travels faster than sound. Depending on the distance from you, it may be several seconds after you see lightning that you will hear the thunder.
This brings up another point: what is heat lightning?
Heat lightning is NOT a real thing! What you are seeing is the reflection of lightning from a very distance thunderstorm. The light bounces off clouds and is transported up to and sometimes over 100 miles. You see the light but do not hear the thunder. No thunder is heard because over the vast distance, the sound of thunder is actually absorbed and muffled out by the surrounding environment and does not travel as far.