Dear student
Thunder is caused by lightning. It is a stream of electrons flowing between or within clouds and the ground. Due to the flow of these electrons, air surrounding the electron stream is heated to about 50,000 oF. Air in the surroundings also get very hot. As the superheated air cools it produces a partial vacuum surrounding the lightning path. The surrounding air rapidly expands and contracts. This produces a tremendous cracking sound. Thundering can be heard 10 miles or more distant from the lightning that caused it.
Regards