We can rationalize and think about what it is. We know what thunder and lightening is, but a dog doesn't.
The loud noise is very scary, and if you have a dog that's very scared of a gun shot, thunder sounds very similar.