How was Texas acquired?

annexed and according to an 1836 treaty, its borders stretched to the Rio grande but was disputed by Mexico and then after a 2 year war the US paid money to Mexico for it. (18 million and change).