Lincoln didn’t fight the Civil War to end slavery — he fought it to keep the union whole. He freed the slaves because it helped achieve that goal.
To a point yes. Remember context is key in history. Without it we have next to nothing.
Lincoln kept slavery out of the spotlight early in the war when the lines had yet to be drawn for a fairly obvious reason.
Washington DC was situated between Maryland and Virginia. Two slave states that had yet to secede with the South. So to say the war was a war on slavery would run a very strong chance that these two states would join the rebellion and Lincoln would be waking up the next morning in the heart of the Confederacy, waving a white flag out of the White House window.
Which is why he waited for military wins, hardened battle lines, and then issued his Emancipation Proclamation. Once people had dug in on sides, that wasn't going to cost him the war.
But it wasn't a secret that he was going to fight slavery. Heck the states listed him being an abolitionist as reasons for secession. Lincoln himself spent his entire campaign trying to play moderate to win votes as opponents just kept calling him a "Black Republican" and wanting to go to war to end slavery. I mean his party was the anti-slavery party. It's like watching Bernie Sanders saying he's not really a socialist when Hillary would call him out on that in campaign mode. Trying to look more moderate wins the maybe votes a lot of the time.
So with his words early on in the war and Lincolns campaign, yeah, not so much about slavery, at least from the North. But listen to that change after the war.
Grant pre war also said it was just about saving the Union.
Post-war he didn't hide his words anymore though...
"There had to be an end of slavery. Then we were fighting an enemy with whom we could not make a peace. We had to destroy him. No convention, no treaty was possible – only destruction."
"but as soon as slavery fired upon the flag it was felt, we all felt, even those who did not object to slaves, that slavery must be destroyed. We felt that it was a stain to the Union that men should be bought and sold like cattle."
"It had to be done... Not only save the Union, but destroy slavery,"
The South called it out from the start, and the leaders in the North called it out once it wouldn't cost them the war. The war was about slavery's existence.
So it's a complicated situation. The war was about bringing the Union back together, but the Union split over slavery. So preserving the union and fighting slavery aren't mutually exclusive reasons to fight a war.