the water droplets and ice crystals inside them collide
and rub against each other, creating electricity.
When there is a lot of electricity in a cloud, it can no longer stay in the cloud.
So, the electricity tries to move to another cloud or the ground.
At this time, what comes down flashing from the sky to the ground is lightning.