Generally speaking, a “gun” works by channeling the explosive force of a propellant down a barrel, driving a projectile (“bullet”) out of the barrel and towards a target.
The same forces are at work, whether using an antique muzzle-loader or a modern-day rifle or pistol.
Modern ammunition carries the primer, propellant, and projectile all in the same cartridge. The process of firing the gun starts when you load the cartridge into the firing chamber. After loading the cartridge, you aim the weapon and pull the trigger.
The mechanics of the gun vary, but a firing pin eventually strikes the primer, which ignites the propellant. The hot explosive gases are channeled behind the projectile, forcing it down the barrel and out of the gun.
There are many variations of “guns,” such as single-shot, revolver, and semi-automatic.