Wars typically have two types of causes, the root causes of the conflict and the immediate causes that actually set the war off. This is true of the Mexican-American War.
The root cause of this war was the American idea of manifest destiny. This idea held that the United States was a country that was specially selected by God to expand across the continent, thereby bringing superior civilization to as much of the world as possible. Americans felt that they were superior both to the Native Americans and to the Mexicans and were therefore entitled to take as much of those people’s lands as they wished.
The more immediate causes of the war centered around Texas. The Mexican government had invited American settlers into Texas some years before. The Americans became discontented with Mexican rule and led a rebellion, making Texas an independent country. Texas asked to be annexed into the US, but was initially refused. By 1846, things had changed. The US now agreed to annex Texas, thus angering Mexico. President Polk wanted a war with Mexico and sent troops into a disputed part of Texas. This caused the Mexicans to attack and the war began.