How did US win the Mexican War?

How did the U.S. win the Mexican-American War?