Were troops on the Union side fighting to abolish slavery or were Confederate soldiers fighting to defend slavery?
gary gallagher points out the primary motivation for Union troops was ideological but not aboitionist, it was Unionist.
For Whitman and millions like him, Union meant “the nation,” but in a way completely unlike the nationalism that often defined public sentiment elsewhere. To them it represented the cherished legacy of the founding generation, a democratic republic with a constitution that guaranteed political liberty and afforded individuals a chance to better themselves economically. From the perspective of loyal Americans, their republic stood as the only hope for democracy in a western world that had fallen more deeply into the stifling embrace of oligarchy since the failed European revolutions of the 1840s. Slaveholding aristocrats who established the Confederacy, believed untold unionists, posed a direct threat not only to the long-term success of the American republic but also to the broader future of democracy. Should armies of citizen-soldiers fail to restore the Union, forces of privilege on both sides of the Atlantic could pronounce ordinary people incapable of self-government and render irrelevant the military sacrifices and political genius of the revolutionary fathers.
When you look at individual soldier's diaries I am told this idea comes out strongly. I don't want to go too far and undermine the idea that people thought about abolitionism in the war but it clearly takes a back seat in popular motivations and only takes a primary place after the war.
Yet a portrait of the nation that is dominated by racism, exclusion and oppression obscures more than it reveals...immigration to the United States promised a brighter future. As one Irish-born Union soldier wrote, “this is my country as much as the man that was born on the soil.” If the Union lost the war, he added, “then the hopes of millions fall” and European aristocrats could claim “that such is the common end of all republics.”
There was a real belief in a version of American Exceptionalism and a belief that America was still a "grand experiment" in democracy that could still fail. As Gallagher mentioned Americans knew about world events, the failures of the french revolution and the revolutions of 1848 (Kossouth had a fascinating visit to the United States after the Hungarian uprising was put down) and these combined with fears of a "slaveocracy"
a piece Gallagher published in a NYtimes blog
http://opinionator.blogs.nytimes.com/2011/04/23/union-proud/?_r=0
I would recommend the 2011 book "The Union War" by this professor as well as the issue of backstory radio on the civil war which involves an interview with him (at backstoryradio.org)
the confederacy was often fighting to defend slavery but i'll let others tak more about that.