Lots of Confederate Soldiers were conscripts who weren't particularly enthusiastic about the war and were just along for the ride.
Others were veterans of the US-Mexico war, who believed they would get some share of the spoils and a path to social promotion by participating in the invasion and plunder of Northern territory. And initially, they were right.
In that same vein, a large number of Northern soldiers were immigrant conscripts either press ganged or duped into enlistment.
So it isn't just Useful Idiots all the way down. Lots of reasons to get mired in the fight.