How did the United States gain territory that would become California, Nevada, New Mexico, Utah, and parts of other western states?