How does lightning and thunder form/happen?
Clouds build up electrical charges through friction. Just like you can build a charge by rubbing your feet on a carpet, all the air molecules blowing around rubbing on each other in the atmosphere also builds up a static charge.
As thunderclouds get bigger, the electrons get attracted to the Earth’s surface so they accumulate in the bottom of the cloud. When a big enough charge builds up, the voltage difference between the cloud and the ground is big enough that the electrons will jump through the air to reach the ground. Going back to the above example of rubbing your feet on the carpet, you don’t have to actually touch a light switch or plug, you only have to get your finger close and the electricity with arc through the air.
When this happens, it makes the air around the lightning bolt extremely hot. This suddenly hot air expands very quickly, which pushes out on the air around it. This creates a pressure wave which makes a very loud sound that can be heard for miles.
The short answer is that clouds form a positive charge and the ground constitutes a negative charge and when clouds build up enough of a positive charge it will release an arc of electricity and literally ground itself.
When lightning forms it releases energy that breaks the sound barrier and the sound you’re hearing is thunder.