Water is one of the single most common molecules in the universe. It is formed of two parts hydrogen, the most common element in the universe, with oxygen, the eighth most common. Water isn't just here, it's everywhere, a lot of it. You can even view water ice on the polar points of Mars. Also, the lightning isn't doing anything, the thunder is what causes that phenomenon.
The water formed over time as various elements settled on a young Earth. Earth does not magically create water from nothing.