The simple answer here is slavery. The Northerners thought that this was a war to expand slavery and the South liked the war because they thought it would give them a chance to expand slavery.
I should say that it's not that the North really wanted to end slavery. They just didn't want it to spread and they didn't want the South to get more political power. They thought that taking a bunch of land from Mexico would let slavery expand and would make a bunch of new states that would have slaves and, thereby, would give the South more political power.
Many northerners were opposed to the Mexican-American War. Many southerners supported this conflict. A big reason for the different viewpoints regarding our involvement in this war was the issue of slavery.
Northerners knew that a victory in the Mexican-American War would lead to the United States gaining more land. They knew this land would be in an area where slavery could thrive because the products that could be grown on the farms that might develop in these new lands would require the need for slaves. The northerners were concerned that many new states would be created from the lands we would receive from Mexico. In all likelihood, many of these states would have slavery. Northerners were concerned this would give the country more slave states than free states. This could harm the interests of the northern states that opposed slavery.
The southerners supported the war because they saw the opportunity to gain more slave states. They knew the lands we would receive from Mexico would be favorable for farming, and slaves would be needed to help farm the land. They saw this war as an opportunity to add more slave states. This might allow the slaves states to pass more laws and to create more policies that would be supportive of slavery.
Slavery was a key factor in explaining why the North and the South had different viewpoints regarding our involvement in the Mexican-American War.