The Union only waged war against states that left the Union.
There were slave states in the Union.
Those are the facts.
The Union only waged war against Confederate states that first declared war on the United States, May 6, 1861.
Why did those states secede? To protect slavery.
What was a major Union war aim? To abolish slavery.
So I ask again, why are you confused about it?