It is due to third law of motion. According to it, force produced by shooting makes the bullet to move, also applies equal force in opposite direction which recoils the gun backwards. It is used to refill gun in semi automatic weapons. When a bullet is fired from a gun, the gun exerts a force on the bullet in the forward direction. This is the action force. The bullet also exerts an equal force on the gun in the backward direction. This is the reaction force. Due to the large mass of the gun it moves only a little distance backward by giving a jerk at the shoulder of the gunman. The backward movement of the gun is called the recoil of the gun.