Part of the apparent paradox is due to the fact that conflicting camps get lumped together under the rubric of "liberalism".
Old school socialism, progressivism, labor politics were not necessarily cosmopolitan and pro-immigration. They tended to oppose immigration on economic grounds and were often tied to populist, nationalist politics. When they did have an internationalist orientation, it wasn't to support the immigration of foreign labor, but to support foreign labor classes in their own countries against exploitation by domestic and international capital. Right-wing capitalist, imperialist, aristocratic politics were often more cosmopolitan.
This old school leftism is dead and was superseded by the Cultural Marxism and neo-liberalism which characterize contemporary liberalism and oppose much of the old leftism while paying lip service to it.