The pals battalions were the government's attempt to solve this problem. They offered potential recruits a kind of carrot: groups of men could join them together, with the guarantee that the group would be kept together in the same unit. You and your mates could go down to the recruiting office and sign up to support each other for the duration. Going to war is a scary thing, so that was an appealing proposition.
An unspoken stick accompanied the offer, of course. It was understood that if not enough volunteers could be found a draft would probably come eventually, and if you were drafted, you'd just get thrown into whatever unit the government chose to toss you into. So if you were a man of military age you were probably going to end up in the ranks one way or the other -- but if you volunteered, you could at least do your service among friendly faces.
The combined carrot and stick worked beyond the government's wildest expectations, drumming up a huge New Army (see https://en.wikipedia.org/wiki/Kitchener%27s_Army) in just a few months. But then that New Army got fed into the meatgrinder of the Somme, and the plan that had seemed so brilliant revealed its dark side as communities across Britain woke up to the realization that none of their men would be coming home.
IIRC some ancient Greek states exploited romantic partnerships to increase esprit de corps in cadres of men. Part of the thinking seemingly being that one wouldn't flee the battlefield and leave a sexual partner so easily as otherwise.
Of course what's good for making a fighting force isn't necessarily good for the rest of society. Or at least there's a cost to that benefit.