This wasn’t so that the Russians could shoot extra-terrestrials, or have space battles with U.S. astronauts. The idea was that in the case of a Russian spacecraft landing in hostile territory, the cosmonauts could protect themselves. This practice is a relic of the Cold War era, though it was only recently put to rest when the Russian government introduce an international treaty banning the transportation of weapons into space.
The gun itself was pretty awesome. It’s triple barreled pistol that could shoot rifle bullets, shotgun shells, and flares. It also comes with a shovel and a machete attached. You could call it the gun equivalent of a Swiss Army Knife. The gun was stored in a metal case between the seats on the Russian Soyuz spacecraft, only to be used in emergencies. After a successful landing, the rare gun was offered to the ship’s commander as a gift.
(Sources: 1, 2)
19 Totally Mind-Blowing Facts