Answer: Texas belonged to Mexico before America got our grubby lil hands on it, and Mexico didn't want to let go of Texas. In the end, however, America and Mexico came to an agreement. The only thing stopping America from getting Texas then was the balance of slave states and free states in America.
I hope this helps! Have an incredible day!! :D