Thank-you for the compliment. 
I grew up in the Mojave Desert, went to law school in Sacramento, lived in Tahoe, and on the Central Coast, worked in San Jose, etc., so I have some familiarity with the topography involved. 
Regarding the railroads:
There are two main lines that run east from Los Angeles. The first runs up over the Cajon pass, through Barstow and thence eastward (Atchison, Topeka & Santa Fe). The second runs through the gap between Mt. San Bernardino and Mt. San Jacinto, down through Indio, and on to Tuscon via Yuma (Southern Pacific). The Santa Fe RR eventually ends up in Chicago via St. Louis. The SP RR eventually arrives in New Orleans, via Houston (IIRC). Note that the SP line crosses no significant mountain ranges between LA and Tuscon. As for the Santa Fe line, while Cajon pass isn’t exactly a piece of cake, it’s only 4000 ft. high, and once over it, the route through Barstow and on to Flagstaff is not that difficult. Much more difficult was the Union Pacific route that went from Barstow through Vegas and on to Utah, but that was only tangentially connected to the LA area, and not the main source of LA commerce.
By comparison, from SF eastward, the rail lines have to get over the Sierra Nevada. Yes, they go through Sacramento, they can head north to Seattle, but in the late 1800’s, that was irrelevant. Commerce was with the Midwest, and through it, to the East Coast. The main pass the railroad takes across the Sierras is 8000’ high. The mountains themselves require more than 50 miles of track to complete the crossing. The line is subject to closure in the winter months from snow. It is a MUCH more difficult and expensive line to ship goods on than either southern route.
So why was it first to completion? Well, primarily because the Civil War precluded an attempt to build through the South, which had been identified as the premium route during the 50’s. The Gadsen Purchase was made in 1853 in order to secure the most efficient route as US territory. But the outbreak of the Civil War put an end to such plans. Instead, the federal government in 1862 designated the central route as preferred, and enacted the Pacific Railroad Act to accomplish this design. It should be noted that the efforts of the “Big Four” in California, all of whom were San Francisco based, had much to do with this decision. It also made much sense, because in the 1860’s, the San Francisco area of California, as well as the Sacramento and Gold Rush regions, was much more important than the then sleepy little hacienda of El Pueblo de Nuestra Señora la Reina de los Ángeles del Río de Porciúncula.
Note that it was completed in 1869, but that by 1883 (a mere 14 years later), there were two southern routes AND a more northern route completed.
Now, look at the demographics for the populations of San Francisco and Los Angeles. San Francisco during the 1850’s went from less than 7250 permanent residents to 56,802. After that, by decade the rate of growth per decade was:
1860's 163%
1870's 56%
1880's 28% 155%
1890's 15% 103%
1900's 22% 211%(!)
1910's 22% 81%
1920's 25% 115%
1930's 00% 22%
1940's 22% 31%
What are those numbers that show up to the right? That’s Los Angeles, which was less than 20,000 in 1880, but which exploded after that. Note the correspondence of this explosion with the arrival of two transcontinental railroad lines in 1882 and 1883. 
So, as we can see, the arrival of the railroads was the initator of population explosion in Los Angeles. In San Francisco, it sustained the population growth through the 70’s, but once the 80’s hit and the rail lines into SoCal had been built, there was less population flood into the Bay Area (yes, I know this also has to do with the relative size of SF and LA, but LA didn’t start expanding its boundaries until the 20th century). And the plain fact is that the rail lines into LA from the East are less difficult to run trains over than the one into SF from the East. 