This is no different than what happened in the Civil War.
Each side had a list of grievances. A big one on one side, was the preservation of slavery in perpetuity. The other side wanted to preserve the unity of the nation as a whole.
You are right that Mexico was not fighting to ban slavery. But it was clear that eliminating slaver was still in their roadmap. Texas had only gotten an extension.
Similarly the election of Lincoln wasn't an immediate threat to slavery in the Confederacy. But the Confederacy still was motivated to head off the long-term threat to their economic system.
So the fact that Mexico wasn't fighting to end slavery, doesn't contradict the fact that Texans were fighting to preserve it.