The history of the United States from 1789 to 1849 is largely the story of our country's westward expansion. The history of the United States from 1849 to 1865 is the story of the culmination of that expansion and the progress of this country toward civil war. The issue of slavery in the U.S. is central to both.
In fact, the origins of the American Civil War include references both to slavery and to the controversy involving westward expansion. Perhaps this timeline will make it clearer, but the two issues come together as the abolotionists fought the idea that new territories and states would allow slavery. Not only would this sort of thing spread slavery, but it would also tip the balance in congress, perhaps further entrenching slavery as an institution in America. They referred to this possibility as " slave power."
Congress attempted to avoid friction between the various parts of the country through a series of compromises. First the Missouri Compromise (1820) and then the Compromise of 1850 tried to resolve the tensions, but were unsuccessful. The Free Soil Party and the Republican Party, both with a strong anti-slavery platform, evolved at this time in response to this tension.
The Mexican American War (1846-1848), itself a controversial war, was also very much a part of this larger controversy. It had quite a significance in the early history of this country, however, and despite the objections of many, it added territory that would become four large states in the nation's Southwest. It also influenced the fame and careers of many political leaders. Look at this list of Mexican-American War veterans. You should see many familiar names, some Presidents among them.