It wasn’t actually more efficient. Having all of you’re guys in a huge box makes it easier to hit than having you’re infantry spread out. It was mostly a morale thing, having other soldiers within arms range made you reconsider running away. While being engaged with huge volleys by these squares made you very much consider if you should run anyway.