Bullet and gun form a system together. Before shooting the bullet by the gun, net momentum of this system is zero. The momentum of the gun is equal to the momentum of the bullet and is in opposite direction to conserve the momentum, when the gun is fired.