Looking at political parties over the span of time there tends to be a
roughly even divide between your liberal party, like democrats in the
USA, and your conservative party, such as republicans, in countries
with first past the post voting systems.
Duverger's law holds that first past the post voting systems (subject to certain conditions) naturally tend to evolve towards two party systems. And the median voter theorem holds that politicians naturally tend to gravitate towards the position of the median voter in democracies.
So, as the views of the median voter evolve, in order to maintain a two party system, party positions and coalitions naturally evolve toward a situation where the more conservative of the two political parties gravitates towards positions close to the political right of the median voter, while the more liberal of the two political parties gravitates towards positions to the political left of the median voter.
If urbanization or any other cause moves the median voter to the left, then the two main political political parties both shift in the direction of the median voter, so that they have roughly equal numbers of members in the long run.
This means that what makes a political party, a politician, or a voter liberal or conservative is always defined on a relative basis with the views of the median voter as a polestar.
To give a same concrete examples, the leading politicians of the American South have been more conservative than those of the American Northeast since the days of the Articles of Confederation in the late 1700s.
But, for example, while Southern politicians in the 1950s were against interracial marriage, and even Martin Luther King, Jr. argued against pushing this point then called "the social issue" on political movement tactical grounds. But by the 1980s there were formerly segregationist U.S. Senators who had staff members who were in interracial marriages because this had ceased to be point of partisan division as attitudes changed over time.
Similarly, former segregationist leaning areas and politicians shifted from favoring de jure discrimination against African-Americans during the Jim Crow law era, to becoming proponents of a "color blind society" and opposing affirmative action.
But political winds can shift the other direction as well.
For example, for a long time U.S. history lessons that sought to be inclusive of non-white people's experiences in the educational system were uncontroversial. But more recently, the conservative movement has mounted a vigorous and widespread effort to oppose the teaching of "critical race theory" in the schools - which is a shift to a more conservative position than the political right in the United States had previously advocated.
More remotely in time and place, in post-WWI Germany, the political views of the people became decidedly more conservative than they were when the organization of the Weimar Republic was put in place, as the crushing sanctions imposed upon the German nation by the Treaty of Versailles led to a severe deterioration of the quality of life for the average German person at a time coinciding with the Weimar Republic era.
Urbanization has been a consistent trend with almost each new U.S. census since the Census of 1790, and has parallels in almost every other developing and developed nation in the world. And, urbanization is, no doubt, one factor among many that has driven a long term trends, only infrequently interrupted, towards more liberal political attitudes. But the causes of this long term political drift in the the leftward direction are almost certainly numerous and more complex than that.
For example, one cannot explain the stark leftward shift of American politics during the Great Depression by urbanization alone. Indeed, the 1930s was a period in which urban populations were relatively stagnant.