If it was all about slavery then why were 5 of the states that fought on the Union side slave states?
The Confederates didn’t want to take over the US government, they wanted to succeed from the Union and form their own country and government where a state’s rights were not interfered with by an over-reaching central government.
Because the economic sectors of those states reliant on slavery didn't have sufficient political power to lead their states into rebellion. Every state that seceded had greater than 25% of its population as slaves. None of the four slave states that remained loyal to the United States had more than 20%, and the average of the four was more like 11% slave. Even the order in which the states seceded, with a couple of exceptions, almost directly reflects their percentage of slave population.