How did the united states gain control of Spanish colonies