Why did the top block(s) move when it gets hit on the bottom?

The top block(s) moved because of the force of the impact from the bottom block. This force is transferred through the blocks, causing the top block(s) to move.