St. Louis native here, and as much as the City/County split is a major topic of discussion around these parts (espcially lately), I don't know of anybody who knows how it actualy got that way. And I understand Baltimore is in a similar situation - is that a result of a similar historical factors or is it a whole different story?
This does not directly answer your question about St. Louis, but Virginia also has cities being independent from the counties. It is he only state in the nation this way. This evolved from the colonial times and codified in the 1970's. Here is a link to good background summary:
http://www.encyclopediavirginia.org/Cities_of_Virginia#start_entry