Although Doctor Strange’s efforts in Avengers: Infinity War are largely heroic, he’s not a hero in the same way that other MCU heroes are. His goal is not really saving innocent people, but largely protecting the integrity of the universe (and now the multiverse). He’s often hesitant to get involved in heroics, and isn’t necessarily considered an “Avenger.”
But in Spider-Man: No Way Home, many argue that he takes on the role of a “villain.” Our hero is Peter Parker, and because Strange's motives clash with Peter’s, he becomes Peter’s antagonist.
At first, the entire conflict is caused by Doctor Strange when he agrees to do a spell that would cause the entire world to forget that Peter is Spider-Man. Wong warns Doctor Strange that the spell teeters on the edge of the dark realm, yet Strange decides to attempt it anyway.
Because Peter alters the spell six times while Doctor Strange is casting it, the spell results in chaos, unleashing villains from other Spider-Man universes into the Tom Holland Spider-Man universe. While Peter and Doctor Strange initially work together to round up the villains in order to send them home. However, when Aunt May convinces Peter that to cure them and offer them a second chance at life in their home universes, Peter and Doctor Strange are at odds.
They fight it out in the mirror dimension, and Peter traps Strange there as he attempts to save the villains from themselves. Suffice it to say that in Spider-Man: No Way Home, Doctor Strange is a major antagonizing force.