Fireflies (or ‘Lightning Bugs’) are a type of beetle and the flashing probably has something to do with mating.
There have been reports of thousands of fireflies blinking in unison, as happened in Elkmont, TN, in 2005.
There are at least 2,000 known species of fireflies, and they rarely travel far from where they were ‘born’.
So, lightning bugs you see in a wooded area are different than the ones you might see in a field.
As one final thought to ponder, the twinkling firefly was once proposed to be the official bug of Indiana!