Firing lines, formations etc. only work at very big scales (thousands of men).
...Which was also the Reason why it was used for a long time in battles.
Its simply there because its almost impossible to organize an army of for example 50000 men(Napoleons Grande Armee was 500000)if they are loosely formated.
In Medieval times, this worked, simply because the Thing that decided the fight in many cases was the big melee.In melee, most formations broke loose anyway, so It didnt make much sense to even try(Although it was used rather effectively by some nations, Romans for example, but they weren´t medieval).
Also, at the times were Firing lines and such were used, the thing dominating the Battlefield was the Musket.Muskets weren´t too accurate, and loosely organized Armys relying on musket didnt work well because they would simply take too long.
Another reason is that the chance of People fleeing and deserting from battle is much smaller with tight line formations.You might want to read Tolstois "War and peace" for some contemporary tales.In Line battles, the presence of the other Soldiers right behind and besides you strengthens the morale, and single soldiers almost never fled.Either the whole unit flees or pretty much nobody did.