It was due to their rivalry with France. Texas is located between Mexico which was a Spanish Colony and Louisiana which was colonized by the French. Texas was not yet colonized at the time but Spain and Mexico realized that the area would be contested until a permanent settlement was set up. The French tried but failed but the Spanish moved to protect their claim to Texas.