The process is a bit different in freely moving bottles when compared to bottles on a solid surface.
Bottles that can't move only foam a little bit, where the hitting bottle foams as much as the hit bottle.
Bottles that can move (even 1 mm is enough) move down faster than the beer. This creates a lower pressure inside the bottle.
Beer can hold a lot less CO2 at lower pressure so any bubble that can grow, will grow and new ones will form at an increased rate.
The top bottle will have an equal but opposite pressure change, but increased pressure just increases the amount of CO2 that the beer can hold so no extra foam will be produced here.
Fun sidenote: If you hit hard enough the pressure in the hit bottle gets low enough to create a small and very short lived vacuum at the bottom of the bottle, the beer rushes towards the vacuum with such power that the bottom of the bottle breaks off. You can also do this with your hand instead of with another bottle. How to Break a Beer Bottle With Your Bare Hands.