How does Newton's third law apply to a rifle firing a bullet?
Rifle and bullet together form a system since they are in contact. So, they have newton's third law applied to them.
Anything, any group of particles numbering from 2 to infinity (theoretically) can form a system.
Since the bullet was inside the gun, they were in contact with each other before the bullet was fired. That means they were part of a system. As soon as bullet is fired chemical reaction takes place ( that rapidly ignites the gun powder which expands at a tremendous rate colliding with the bullet and pushing it from its shell - once again bullet and shell form a system. Shell heats up, and bullet gains energy - and the bullet which expands out of the gun. In other words it looses contact with the gun.
Newton's third law states that in a system, there are equal and opposing forces. Hence, when a constituent of a system leaves it, it leaves its so called trace marks behind a.k.a momentum in opposite direction. Hence, Gun goes back in proportion to its mass and bullet moves forward due to its exploding gunpowder.