I can't speak for the others, but when Sacramento became the capitol of CA (1854), it was significantly larger than Los Angeles.
Los Angeles's explosive growth didn't start until the 1890s.
Keep in mind while reading this that I am NOT a historian. Most of this information was found from school textbooks back in the day, or online, or even heard from friends or read here on askhistorians.
Sometimes in the past the capital city was larger than other cities. Other times, a new city was built in a strategic spot, like WA, DC, as a result of a political compromise
While other times, it had a historical/cultural significance that the conquerors of that territory could tap into.
For example, Constantinople was made the capital of the Ottoman empire after it's conquest in 1453, even though the previous Ottoman capital Edirne (Adrianople) had an estimated 70,000 people in it, while Constantinople is supposed to have had 50,000 people (A massive decrease from it's peak of around 400,000 people).
After Mehmet II captured Constantinople, he declared himself Kaiser-i-Rum (Caesar of Rome). He had conquered perhaps the most historically, culturally, and politically profound cities in Europe. So why not use that legacy and that history to his advantage, by building prestige for himself and his empire?
Meanwhile, Ankara became Turkey's capital in an effort to remove itself from the 'old world' of Istanbul which the new government had rebelled against, amongst many other reasons.
Generally speaking, those are the reasons why a smaller city might be a capital.
The reasons are different in each case. Often, there was a desire for a central location, whereas the largest city was a port on the edge of the state. There was also often a desire to "spread the prosperity around" rather than focus all economic and political power in a single large city. Finally, there was often a perception that large port cities were rife with corruption or were filled with recent immigrants whose politics or culture might be distasteful to some of the decision makers.
It's often a deliberate compromise between those very powerful cities. This is for instance why Canberra became the capital of Australia - it could not be decided whether Melbourne and Sydney would be the capital, so all instead agreed on a third location between Melbourne and Sydney.