The conservation of momentum is the consequence of Newton's third law. When a collision between two bodies occurs, then the force applied by one body is the same as the force applied by the other body but in the opposite direction. The bodies contact each other simultaneously; therefore, the time for both the bodies remains the same. Since the impulse is the product of force and time, therefore, the impulse is the same for both the bodies. Moreover, the impulse is the same as the momentum; therefore, the momentum is also the same. Hence, the momentum remains conserved during the collision.
The momentum is conserved during the collision only, but if a box slide on the table, then the momentum will be not be conserved as there is no collision during the sliding of the box.