The US and Texas did not go to war with each other. US settlers that moved to the Texas territory of Mexico decided they didn't like Mexican rule, even though they moved to Mexico, and rebelled. They won, with the help of many US volunteers. Then Texas joined the US, then the US and Mexico went to war and the US took California, Arizona, and New Mexico as well.
The only time Texas fought against the US was during the Civil War as members of the Confederate States, and that was some years later.
Ya, that's what we're talking about. Texas declared war on the US, along with the rest of the Confederacy, and the US won. The question of who the rightful owners of Texas was got decided at that point. Any previous claims to the territory were invalidated.