Cavalry will encircle enemies in exactly the way you described, but infantry won't.

Perhaps the reason why is that infantry would be exposed to counterattack, which they can't avoid as easily as cavalry.

For example, in your second image the black-colored units on the right would be a ripe target for a devastating cavalry charge from the Northeast direction. Mounted units can pull out and avoid the charge, but it's much harder for infantry to do this.