They didn't.
What happened is that after multiple decades of systemic mismanagement, the Dems successfully chased out a huge number of people and businesses. At the same time, in 2019, DeBlasio ramrodded the NYC's Sanctuary City policies through unilaterally. Throw in years of selective crime enforcement, high taxation, and general policy paralysis on anything but what the fringe left wants, and they effectively supplanted the existing voterbase over the last two decades.
This chasing off countless New Yorkers wasn't a bug - it was a feature. They don't give a shit if it scares off existing businesses and people - it creates a power vaccuum they can immediately fill in with their own people. This is, by coincidence, also exactly what the Obama administration did to Minnesota, lest you think this is an aberration, by the way. The idea is that even in states that are otherwise trending red or outright red, this creates highly disruptive regional territories with a vested interest in pushing insane bullshit policy, with a landed voterbase that will never, ever vote them out.