Each of these compromises tried to maintain the balance between slave states and free states.
Part 1:
The Missouri Compromise (1820) admitted Missouri into the Union as a slave state with Maine being added at the same time to keep the balance of slave and free states equal. It also prohibited any future slave states north of the latitude line 36 1/2 degrees north of the equator in territories of the Louisiana Purchase, with the exception of Missouri (north of that line) being admitted as a slave state.
Part 2:
The Compromise of 1850 was passed after an attempt to have all new territories be non-slave states. In 1846, Congressman David Wilmot of Pennsylvania introduced an amendment to an appropriations bill, stipulating that any territory gained from Mexico (after winning war vs. Mexico) would be free, not allowing slavery. [Don't think of Wilmot as an abolitionist, though. He wanted new territories to be free of blacks, preferring whites-only territories.] Wilmot's amendment passed in the House of Representatives, but was unable to get approval in the Senate. The Compromise of 1850, a package of five bills passed by Congress in September of that year, sought to accommodate some of the issues both South and North were debating over during those years. The balance between slave states and free states continued to be an issue.