IDK, I that implies a level of calculation which you don't really get in the heat of battle. Generally feelings about not wanting to let down yourself/your comrades are more important. (Actually, that would suggest a possible explanation: USCW soldiers were generally sent into battle without a huge amount of training, so maybe they didn't have time to develop the levels of esprit de corps necessary to charge a line of enemy riflemen?) Plus, it would imply that units which are/were drawn disproportionately from wealthier social strata (e.g., cavalry, guards units) ought to be less willing to close with their enemies, which I don't think seems to be the case.
While I can't speak for all troops everywhere at all times, there are two basic aspects to the matter: why the soldier joined up in the first place (patriotism, conscription, financial reward, escaping intolerable situation elsewhere, a sense of adventure, many possible reasons); and why that soldiers stays put in the line of fire when the elephant comes along, and the soldier has not merely seen the elephant, but damn near gets trampled underfoot by a flock of the blooming things.
The discussion is basically covering the second aspect. In modern forces, there is one over-riding reason why soldiers stay to do their job. It's because you don't want to let your mates down. Lots of people talk about patriotism and adventure and a sense of duty and all the rest of it, and they're talking hogwash. It's your mates with you that are key.
We can go back to WW2, and we see the same. MacDonald Fraser describes it better than I can in Quartered Safe Out Here. We can go back to WW1, and we see similar views being expressed in letters home; apart from wanting to come home safe (and the constant, never-ending complaints about bad food), one gets an over-riding sense of connection between the soldier and his immediate squad.
The further back one goes, the harder it is to know for sure, but such evidence seems to suggest that it holds true. Rifleman Harris in the Peninsular Campaign talks of comradeship as being a stiffening virtue.
For the specific case of the ACW, my understanding is that a lot of units were drawn from very close geographical areas, and the members of a unit might very well be neighbours in civilian life. They already know each other, and are half way to forming that bond of mutual trust (only half-way, because it's only when the elephant is rampaging around that you know for sure).
How that affects operational decisions is a separate issue. One sticks by your squad, but whether that means marching together into an inferno of fire and shot, or doing an impression of moles and burrowing deep when a twig snaps two miles away, or, in the immortal words of Kipling: "Take open order, sit tight, and pray for support like a soldier" will depend on what you've been taught.
Again, in the specific example of the ACW, pretty much everyone was learning as they went along. The forces that fought at First Bull Run were not much like the forces that fought at Gettysburg, or carried out the March Through Georgia. It's not really appropriate to talk about the soldiers of the ACW as though they were of the same quality from start to finish. The forces at First Bull Run could probably have been beaten by a couple of well-disciplined European regimental mascots (OK, maybe I exaggerate), while the mid- and late-war Union Western armies seem to have been pretty competent compared with any other force anywhere in the world at the same time.