Two balls approach head on and touch. While they are in contact, the first pushes the second and the second pushes back on the first.
These two are an action and its reaction. Opposite in direction and equal in size. It makes no difference how violent the collision is; this always holds.
It is tempting to think the heavier ball pushes harder, but it does not. The forces they exert on each other are the same. What differs is how much each one's velocity changes under that force.
The figure shows the two arrows during contact. They are the same length and opposite in direction. Their strength varies, but the two always vary together.
Equal forces still give unequal impulses if they act for unequal times, so the time has to be checked as well.
The contact is one single interval shared by both. The second ball is in contact for exactly as long as the first is. Obvious as that sounds, it is what makes the argument work.
Same force and same time means the impulses are the same size, with their directions still opposed.
The two graphs in the figure are the same shape flipped upside down. Equal in area, differing only in sign.
Impulse was the change in momentum. So the change for the first ball and the change for the second are equal in size and opposite in direction.
Written out, , and rearranged, .
That is to say the sum of the two momenta does not change. What one gains and the other loses cancel exactly.
This is the law of conservation of momentum. It can be read as the law of action and reaction restated in terms of momentum instead of force.
Everything so far concerns only the forces the two exert on each other. These are called internal forces, and internal forces always cancel.
What cannot be cancelled are forces from outside. Hit a wall and the wall pushes; run on a floor with friction and the floor pushes. Then the total does change.
That is why the simulator track has neither wall nor floor. Its left end and its right end are joined at one and the same point, so nothing acts on a ball passing through. A state with no external force at all has been built on purpose.
There are three bars in the figure. The upper two jump at every collision, and only the total at the bottom stays still.