Lightning always precedes thunder because lightning causes thunder.
A lightning bolt can heat the air it passes through to temperatures as high as 54,000 degrees Fahrenheit. It is the quick and intense heating of the air that generates shockwaves, which propagate rapidly away from the lightning bolt. These shockwaves become soundwaves as they travel through the air. This is how thunder is produced. Sometimes thunder rumbles on long enough that you see another lightning flash, which could lead to a false conclusion that thunder comes before lightning.