Oil has several advantages over coal as a locomotive fuel... it has a higher BTU content than coal has, no cinders are created from oil's combustion (cinders cause some major issues with tube life due to cinder cutting) and oil is easier to work with for the fireman.
Coal was used on most roads due to lower cost... in the late 19th Century, the PRR looked into oil as a locomotive fuel (due to it's then lower cost than coal) but decided against it due to the fact that their conversion to oil fuel would raise the price to the point where it was more expensive than coal.
Due to the lower price of oil on Western railroads, oil was the fuel of choice, except where coal was readily available... all of the major western railroads that used oil also used coal on some portions of the railroad, where it was available locally (yes, even SP used coal fired locomotives on the former EP&SW and Rio Grande divisions until the contract with the Dawson mines in New Mexico expired in 1949.)