It is a relatively simple maneuver. It begins with two infantry forces of varying strengths engaging in a frontal assault. While the infantry lines are fixed in the engagement, a cavalry force maneuvers around the enemy and attacks from behind, sandwiching it into the friendly infantry. Generally, the force attempting the maneuver needs to have a superior amount of cavalry to be successful.
It was popular in a number of battles throughout the Classical period. In addition to being used in many of Alexander the Great's battles, it was also used during the Second Punic War during the Battle of Cannae and the Battle of Zama.
Many generals have used the tactic of a "hopping" hammer and anvil. That requires the cavalry to be a "hit-and-run", relying on the impact. The "hopping" maneuver relied on the cavalry hitting an extreme left or right flank, then hammer-and-anvilling towards the center of the infantry. That would weaken and rout the entire flank, leaving the remaining forces to run down the scattering enemies.