Mostly it was manifest destiny. This was the idea that the United States are destined to connect the two coasts and since California is located on the western coast it was logical for the government and all subsequent ones to work towards procuring California, as well as the Oregon region and New Mexico and all that took them westwards.