The centre fire pistol cartridge is constructed from four basic components: cartridge case, primer, powder charge and bullet. When the hammer of the handgun falls, it strikes the firing pin driving it into the centre of the primer of the cartridge seated in the chamber. This impact causes the primer to flash, igniting the powder charge, which burns rapidly creating gases, the pressure of which forces the bullet out of the casing and down the barrel, the path of least resistance. The rapid expansion of gases does not "explode", but when the bullet leaves the muzzle of the handgun, the superheated gases impact with the cooler air outside the barrel, creating a shockwave which your ears hear as the "bang". The handgun recoils as the bullet leaves the muzzle, but, not as a result of an explosion, but a reaction to the forward momentum of the bullet.
When the flash from the primer ignites the powder inside the cartridge case, it begins to burn very rapidly. This rapidly burning powder creates gases which heat to very high temperatures. The heating of the gases increases its volume and, therefore, increases the pressure inside the casing, forcing the bullet out of the casing and into the bore of the barrel. Since the bullet is slightly larger than the inside diameter of the bore, the surface of the bullet is forced into the grooves of the rifling inside the barrel. This expansion is known as "obturation" and it seals the barrel so that the still expanding gases are trapped behind the bullet and must force it down the barrel and then, upon leaving the barrel at the muzzle, down range toward the target.
Pistol powders are designed for a rapid burn due to the short barrel length involved. The powder burns as the bullet travels down the barrel and out the muzzle, accelerating as it moves through the bore. It reaches maximum velocity as it leaves the barrel which causes the handgun to recoil because of Newton's third law of motion - "action and reaction". So, when the gas from the burning powder forces the bullet forward, the handgun recoils backward with equal momentum.
As the bullet leaves the muzzle, the super-heated gases behind it are also released, colliding with the cooler ambient air ahead of the muzzle. This collision of super-heated gas and cooler air results in a "super-sonic bang", as the bullet is traveling faster than the speed of sound.
The muzzle velocity of a .22 or .38 special or .357 magnum revolver bullet also exceeds that of the speed of sound which is 1,126 feet per second or 767 miles per hour, and if the bullet is travelling super-sonic, it too makes a "bang" as it travels through the air.