I've known for a while that it was southern democrats fighting northern republicans during the civil war, but it just recently crossed my mind: why were the democrats in the south supporting slavery and seceding while northern republicans supported freedom and keeping the union together, when in today's terms the stereotypical democrat and republican are switched on issues like this and relating to it?
This is a question I have fielded many times in introduction courses to American history. I think the first aspect of the question that needs to be addressed is the idea that is that Southern Democrats or Northern Republicans "switched sides." The reality is that to compare the Democratic or Republican Party of 1860 with their modern iterations is incredibly distorting. While I am no expert on modern American politics, the Democratic party of 2016 can be more closely associated with the Democratic Party of FDR, which promoted the American version of the welfare state in the early twentieth century. As for the Republican party, the big change within this party occured during the Civil Rights Era when many Southern Democrats, like SC's Strom Thurmond, switched their party allegiance to the Republican Party after the passage of the Civil Rights Act of 1964.
If you are to look to the election of 1860, which brought Abraham Lincoln into the White House, you'll notice that there were really four parties that put up legitimate candidates for the White House. While Abraham Lincoln was eventually chosen to be the Republican nominee, his selection came as a surprise to many who favored other choices including the eventual Secretary of State William Seward. The Democrats, on the other hand, had suffered a serious party split during the Nomination Convention that took place in Charleston when the "Fire Eaters" (that is those Democrats who opposed any Federal legislation restricting slavery in the United States) walked out of the convention and later nominated their own candidate, Stephen Breckinridge, to represent the Southern Democrats.
However, it would also be wrong to explain the election of 1860 looking at only Breckinridge and Lincoln. The electoral votes for Virginia, Kentucky, and Tennessee went to the Constitutional Union Party candidate John Bell. This party was made up of men from the former Whig party, Know-Nothing Party, and even some Southern Democrats who disagreed on the future of slavery in the United States. In addition, many historians have demonstrated that though Lincoln is known as the "Great Emancipator," at the time of his election he was not intent on freeing the slaves in the states where slavery existed. Instead, he simply intended to keep slavery from spreading.
Finally, this answer also needs to take into account the failure of Republicans during Reconstruction that was finalized with the Compromise of 1877 that brought Republican Rutherford B. Hayes into office at the expense of the most radical reforms and occupation of the South. Despite the passing of the 13th, 14th, and 15th Amendments, following the removal of the US Army from the former Confederacy, Southern Democrats were able to reinstate Jim Crow laws that eliminated African American rights to vote among a series of other restrictions.
TL;DR- It's not accurate to compare the "Southern Democrats" and Republicans of the late nineteenth century to the modern political parties. In addition, it also isn't accurate to say Southern Democrats fought Republicans during the Civil War because the dividing line was much more ambiguous that simply Democrat versus Republican.
Sources:
Forbes, Robert. The Missouri Compromise and Its Aftermath: Slavery and the Meaning of America.
Doyle, Don. The Cause of All Nations: An International History of the American Civil War.
Foner, Eric. Reconstruction: America’s Unfinished Revolution, 1863-1877.
McPherson, James M. The Battle Cry of Freedom: The Civil War Era. Gallagher, Gary W. The Confederate War