A phalanx was more organized, forming up in straight lines and able to execute pretty complex maneuvers: in order to move from eis bathos (a loose marching formation) to pycne (combat formation) to synaspismos (a locked shield formation used to hold one’s ground against enemy pushes) and back, in which the phalanx would alter its length and depth (from eight men deep to up to 60-odd deep) to gain various advantages.

Likewise, when the fight started, the hoplites of the phalanx were trained in particular techniques for various stages: there was training for the krousis (the moment where the two phalanxes would crash into one another), there was training for the doratismos (where both sides are stabbing at the other side with their spears trying to disrupt the formation; in this phase, there was a specific maneuver whereby anyone who was killed or wounded would be dragged backwards while the men behind stepped forwards to prevent gaps from opening up), there was a lot of training for the all-important othismos (”the push” where the phalanxes would, having refilled their lines, literally push from the back ranks forward, adding their weight to the elite men in the front ranks to try to topple the other side over – you can think of phalanx warfare as somewhat similar to a rugby scrimmage), and then the pararrhexis (where one formation would break and the other would push forward into the enemy formation and send them fleeing).
As you might guess, coordination was key here and there was a surprising amount of strategy involved for what sounds like a giant shoving match. A deep sixty man formation would be very difficult to defeat in the othismos, but its narrow frontage would leave it vulnerable to flanking; a thin eight-man formation might break during the othismos, but its extended wings might be able to outflank a narrower formation – and because phalanxes were incredibly vulnerable on the flanks and rear, you could win without triumphing in the push. So on the battlefield, there was a fair bit of formations dancing around, trying to get the other one to over-commit, or to match their maneuvers with counter-maneuvers.

Shield walls, by contrast, were much simpler formations – they were less mobile, there were generally fewer lines and what lines there were tended to be less drilled in maneuvering in line, they couldn’t change depth or length very easily, there wasn’t the elaborate pushing, reforming, pushing, breakthrough techniques used by the hoplites, etc.
The difficulty with the phalanx, is that it takes a good deal of resources to support a hoplite class dressed in heavy plate from head to toe who can spend all their time learning all of these marching drills and techniques. A shield wall is way simpler, and you can train peasant levies who show up with just a helmet, a shield, and a spear how to do one pretty quickly. So while a phalanx might be higher quality than a shield wall, it’s less replacable – as the Spartans found out to their dismay after losing only a few thousand soldiers against the Thebans.
Moreover, the phalanx is incredibly vulnerable on its flanks and rear – as is a shield wall. Which is why, once they figured out how to ride horses effectively, the knight becomes so devastating on the European battlefield, because they could move in quickly to attack those weak spots and the sheer shock and force of the impact of a moving horse against a human being.
