Well you need to look up the history of the 13th amendment. Turns out the guys who fought to preserve slavery were for the most part not in the Southern state legislatures then. It was the reconstructionist Republican legislatures who approved that amendment. Some states like Mississippi never ratified it.
So what was the war about?