It can still make sense, but it's very involved. Right now, it sounds like this:
This agent has been on the MC's side this entire time. But they've gone to the antagonist side to scope out information.
Now, if the antagonist side has ordered this double agent to watch over the MC, then them being nice in front of the MC makes sense because they're trying to keep their cover well:
If they don't act "nice" to the MC, that blows the cover of the antagonist side. And if the antagonist side finds that out, that blows this agent's original cover.
So them being nice in front of the MC is their cover for the antagonist side. And them being horrible behind the MC's back still maintains that cover so that the antagonist doesn't realize they're a double agent.
Think of it like FBI agents going undercover in a mafia or any type of criminal outlet . If they're really deep in their operation, they cannot, in anyway, let it known that they're undercover. They might even have to do double, triple, undercover to keep up the act.