Mexico attacked us first.
Mexico never recognized Texas's independence from 1836, and always considered it their sovereign territory.
The United States chose to annex Texas after various negotiations (initially secret) during the Tyler Administration. (The annexation of Texas didn't even properly specify the actual borders of the territory being claimed!)
When we annexed Texas, Mexico — having warned Secretary of State Abel Upshur multiple times previously that annexation would result in a declaration of war — followed through.
Any detached viewer of military history can see that Mexico's casus belli was justifiable.