A thunderstorm or electrical storm is caused because of larges imbalance in electrical charges caused by friction in clouds. Clouds become charged due to movement of ice, water droplets and soft hail.
The friction causes movement of electrons and leaves the top of the cloud positively charged and the bottom negative. Lightning strikes can take place within the same cloud, between a cloud and another cloud or between the cloud and the ground.
Lightning strikes can separate oxygen diatomic molecules into individual oxygen atoms. These individual oxygen molecules can reform into triatomic oxygen commonly known as ozone. This explains that smell that people associate with an impending storm.