A combination of factors made it happen. First up, you had low turnout. Only 20.5% of voters actually voted in that election, the lowest of the past 30 years.
Aside from that, Adams had strong support amongst voters of color. For people who don't live and/or work in these communities, it can seem like voting against their interests and be surprising, but non-white voters are not a monolithic block. Quite often, majority black or Hispanic neighborhoods in the Bronx can prove more conservative than many people might expect, for example, particularly on social issues. A lot of my older co-workers from Latin America at the time, along with my mother-in-law, didn't view BLM protests as legitimate actions to begin with, and just thought of them as troublemakers looking to break stuff and loot. The "tough on crime to raise quality of life" message was really powerful for many of the people I know, and they took it completely uncritically. There's also a ton of super religious folks that won't support Democrats over things like LGBTQ+ rights, abortion, and other culture war GOP talking points. I can't really speak to the Black community, but if you learn Spanish, there's also just a ton of casual racism, sexism and homophobia that would probably shock people.
In addition to conservative social inclinations, lots of these folks are not what you would describe as well-informed. My elderly Ecuadorian, Dominican and Peruvian co-workers at that time were constantly buying into totally baseless conspiracies they got sent on WhatsApp. That and the 2020 presidential election cycle was super frustrating at home, as my mother-in-law would religiously watch the news on Univision, where they would trot out "scandals" and conspiracies that had been disproven weeks earlier and abandoned in the English-media, but Univision knew they could get away with airing for the significant portion of their audience with limited or no English. I even remember watching the news with her, my wife and her sister, who are both fluent in English, and the three of us getting upset that an interview in which we could hear the original English statements were being translated entirely inaccurately.