Call That a Formation

In ancient warfare, or indeed modern warfare before the advent of accurate rifles, armies generally kept in some kind of formation. Well, some armies, anyway. The Celtic peoples of Roman and Greek times were exceptions to this rule. But armies like the Romans, Greeks, generally any spearmen on any battlefield, and any modern European army, all stayed as a block of troops and worked together in a distinct formation.

That's Real Life. Fiction is different. This trope covers situations where you see armies, which should be in a distinct formation, fighting out of formation.

That said, some things you'd expect to be unrealistic, like having soldiers wielding different weapons from each other in the same group of soldiers, aren't necessarily wrong; towards the end of Medieval warfare, knights generally fought with the support of several warriors of lower status armed with weapons, and fought in smaller units. And as soldiers were often required to arm themselves, those of lower status would often have to bring whatever they could to hit the enemy with. The warfare during The Wars of the Roses is an example. Generally though, warriors of different social standings fought separately from their collegues.

Even cavalry, who you wouldn't think of as having a formation, can fall victim to this. For example, Alexander's cavalry would have often charged home in the wedge formation.

A big exception is once battle is joined. The most disciplined forces, like Roman and Greek soldiers, would try to maintain formation under all circumstances, and pike and spear walls would likewise attempt to maintain the integrity of their formation. But war is war, and at some point the formation is going to dissolve or at least weaken. So if there's heavy melee fighting going on, it's acceptable to see soldiers dueling it out as individuals. Expect to see historians face-palming if phalangites are charging in with swords mid-melee however. Same goes for Roman legionaries willingly coming out of their famous shield wall.

A subtrope of Hollywood Tactics.

There are as many variations of this trope as there are armies. Please do some research before adding examples of this trope.

Film

 * Played depressingly straight in Braveheart. The Scots fought as disciplined pike formations, it was their lack of armour and cavalry which made them so vulnerable to the longbow. (and what wasn't in those days?) They would not have charged wildly into battle, but advanced in disciplined rows in order to push back cavalry and infantry with massed ranks. The Scots didn't win the battles where they managed to close for battle with the individually more skilled English knights for no reason.
 * It inadvertently shows the effects of not fighting in formation. We're supposed to believe the Scots "won" at Stirling because the few dozen guys still standing at the end are Scottish—even though losing as many soldiers as they did would be a catastrophe.
 * Only somewhat averted in the The Lord of the Rings movie - most battles quickly devolve into total chaos but the most disciplined soldiers on both sides do keep formation at least when taking an enemy charge (most notably elves in the prologue, and the uruk hai taking the reinforcements' charge at Helm's Deep).
 * The Uruk example is really bad, since cavalry charging massed pike should have been massacred. There however it is implied Gandalf is making the sunrise much brighter so the Uruks with the pikes are too disorientated and blinded to fight back against the downhill charge of the horses. When a similar charge occurs at Pelennor Fields...not so much.
 * However both armies use mixed weapons, with archers/crossbowmen firing from inside the formation.
 * It was a common tactic for skirmirshers to take cover in infantry ranks. Archers could be trained to do it as well.
 * At Pelennor Fields, however, the Rohirrim were fully expecting to die in that charge. Remember Theoden's Rousing Speech? What looks like what happened is that the orcs were expecting them to break off the charge when confronted with the wall of massed pike and the flurry of arrows, and then broke formation when they kept coming. Also, the orcs' spears were really short and very poorly made, as opposed to the long, well-forged Uruk-Hai pikes.
 * The objection to cavalry charging pikes is not that men don't do such things, because men are capable of being suicidally brave. The objection is that horses are rather less so. Aside from that, the Rohirrim wanted to get a few good licks in in any event and had enough self-respect not to pull an embarrassing stunt like that. In point of fact, in the book they caught the enemy completely by surprise and were having a jolly time slaughtering unformed troops at the beginning of the battle. The first organized response was a cavalry unit of men not an infantry one of orcs.
 * In the prologue Elrond's elves are shown maneuvering a phalanx with inhuman precision.
 * In 300, the Spartans alternate between fighting in formation and fighting out of formation; notably, while fighting the first persian waves they fight in a tight phalanx formation, and break once they've killed the majority of the Persian troops to charge into them. Later when the Persian cavalry arrives, the Spartans adopt a tight arrow-shaped formation. The Spartans have some trouble fighting the Immortals later on until they manage to form up into a phalanx when the Arcadians distract the Immortals, and they also use a shieldwall when fighting the Persian elephants. The only times the Spartans are shown taking losses are when they fight outside of formation, such as initially against the Immortals, when the grenadiers attack, and when a few Spartans range out ahead of the rest of the formation and get hit by cavalry.
 * And, of course, its possible that they never actually broke ranks at all, and it was just a tactic by the Unreliable Narrator to make the deaths look more heroic.
 * In the opening battle scene against the Germanic barbarians in Gladiator, the Roman legions advance in a decent formation -if a bit crooked due to rough terrain- until the German horde smashes into them. When that happens they immediately break up into a swirling melee. Although they win the battle, the scene does (perhaps unintentionally) illustrate the reason formations were so necessary to the Romans in the first place- in the morass of single combats that followed, the huge Germanic chieftain is almost unstoppable until he's brought down by sheer weight of numbers, demonstrative of the manner in which the powerful but undisciplined barbarians made war.
 * In the 2010 Robin Hood, you see a line of defenders form a spear wall behind their gate. when the enemy horses drive through...ther're gone. in other battles, you see french soldiers make a few thin lines, but they dissolve before the enemy is within striking distance at no provocation. so, there were formations, but they never got used...I really dont know what the director and or fight choreographer was thinking.

Live Action TV

 * Averted in Rome. Caesar's legions are shown forming a testudo (turtle, wall of shields) and rotating their troops in a disciplined way. Legionnaire Titus Pullo leaves the formation and is punished for that.
 * Played with later at the battle of Philippi. Both sides start in organized formations but the battle later degenerates into a massive confused brawl. We can later see that Octavian and Anthony's forces have the clear upper hand when significant numbers have reformed into tight formation to advance toward the command position of Brutus and Cassius.

Tabletop Games

 * Averted in the Warhammer Fantasy Battle tabletop game. While skirmishing units have a serious mobility adventage, the ranked soldiers gain a "rank bonus" when calculating the winner of a fight, making large, ranked units very difficult to shift. Skirmishers or lonely heroes engaging a ranked unit in a frontal assault are likely to be pushed back even if they deal more damage.
 * And almost every unit has soldiers equipped with the exact same weapons, except for the command groups, though that may be the player trying to cut bown on bookkeeping more than anything else.

Video Games

 * Thoroughly averted in Total War, which demonstrates why this is a bad idea. You see you get several units who stay true to this trope... and they tend to get massacred horribly in melee. Equally going into scatter formation and then charging is a good way of getting your soldiers killed off. Generally, units that were in formation are and units that shouldn't be in formation aren't.
 * However, urban combat turns your nice, neat formations into a chaotic mess, especially if you're ordering more than one unit down a street at the same time. In that case, your soldiers turn into a tightly-packed mass of swords, spears, and other pointy and/or bladey instruments of death. This can be both good and bad; bad because your troops are mixed and you've got archers with daggers fighting alongside heavily-armored knights, and good because you can pack more pointy and bladey into an area and meatgrind enemy troops under a morass of troops. Just hope the enemy doesn't have catapults or cannons.
 * Played with in Dragon Age during the battles at Ostagar and later . In the Ostagar battle, the Ferelden troops charge the darkspawn (who have no formation at all beyond being a simple wave) in a rough line and meet them outside the fortress walls. Also, Loghain's troops are shown to be gathered in a sensible, if very thick and deep, formation. The battle devolves into an uncontrolled melee as it progresses, but this is partially because   Later, in , when Arl Eamon's troops charge the darkspawn, the initial charge is shown as a block of soldiers advancing in a tight formation when they hit the darkspawn lines. Weapons are also notably very mixed in the Ferelden army, with sword-and-shield and two-handed weapons troops mixed together, though it is implied this is because Ferelden's army isn't the most cohesive. We do see single-weapon formations a few times in the game, most notably Loghain's army and the Cousland troops in the Human Noble origin.
 * The mix of weapons is actually justified in universe soldiers had to supply their own weapons or buy one from the quartermaster, either way many would have different types of equipment.
 * Averted in Neverwinter Nights Hordes of the Underdark with the Elistraeeite drow, who fight in small similarly-equipped units and stick to regimented formations before the Duregar Zerg Rush turns the battle into a chaotic melee.
 * Averted in Overlord II with the Glorious Empire. The player character is a roughly nine-foot-tall monster of a man in diabolic armor that wields equally huge and evil weapons, throws magic around with his free hand, and commands an army of psychotic gibbering minions. Needless to say, when catching small groups and individuals, the results are usually (and hilariously) one sided. Then the soldiers get into formations: shield-bearers are nigh invulnerable and cannot be individually targeted, and archers fire in uniform volleys that will devastate your horde. That is, until you make them break formation by killing their commander, siccing the wolf-riders on them, or lob a few catapult boulders/bombs their way...
 * Averted and played straight on Fire Emblem Genealogy of Holy War, where many enemy armies come in formation and try to stay on it (As much as the game design lets them), but you still see enemies scattered around like in the rest of the series.
 * Averted in the second and third Age of Empires games, where several formations with different uses are available. Units will adhere to these formations to the best of their ability, ordered appropriately (strong melee in front, weak ranged in back, etc), until they engage the enemy. Played straight in the first game, before they had the things we take for granted today, like decent pathfinding and good mass-unit controls.
 * Although a staggered formation was virtually king in the second game since it allowed you to take less area of effect damage from siege weapons with virtually no real issues. While a packed line formation remained better for musketeers attacking cavalry in the third game due to being more able to use their hand-to-hand attacks easier which are superior against them as opposed to shooting, the light infantry of the game tend to be always pitiful in melee compared to their ranged attack, meaning a spread formation remained the only logical thing to use for them - especially since everything was Friendly Fireproof, even firing into a melee.
 * In Guild Wars, everyone seems to fight in small, loosely-formed squads. Since due to area-of-effect magic most players deliberately avoid standing too close togiether, this may be Justified
 * In Dwarf Fortress, a melee dwarf will charge an enemy as soon as it gets close enough. Situations this leads to: lone charges on enemies large enough to use a dwarf for a football, ignoring sniper-class bowmen in favour of their unthreatening bodyguards, ignoring specific kill orders in favour of the closest opponent, and never ever retreating (or even following a 'move' order) as long as there's something to attack. Ranged dwarves who've run out of ammo consider themselves to be melee dwarves. Since they're usually equipped with leather and bone and have no combat training, this ends about as well as you'd expect. Really, the best you can do is station the lot of them around a corner somewhere and wait for enemies to walk into the mobile meatgrinder.
 * Of course, with enough training and sufficiently legendary equipment, a lone dwarf champion charging into a mass of besieging goblin forces can actually work.
 * Averted in Warhammer Dark Omen: Regiments move and fight in formation and a tight one defends better against charges while a loose one is better for ranged fire. If a unit routs, it loses its cohesion for a a while and it's an easy target.