The fact that many larger cities are controlled by Democrats is a very interesting phenomenon that I do not fully understand.
My guess has always been that the difference comes about because smaller communities can organize to solve problems without government help, so they lean towards 'limited government'. Larger communities have a naturally harder time organizing, and so they lean towards government programs.
If your community is 1,000 people and 1% of your population is homeless, you probably know the names of all 10 people and figure out a solution case by case. If your community is 10,000,000... that's 100,000 homeless people, which is a wholly different problem.
If you find crowds of strangers exciting in a good way, you move to the city. If they excite you in a bad way, you move away from the city.