ok but the thing that drives me up the wall with the megamind fandom is this pervasive idea of "oh he was actually good the whole time, he just needed to be given a chance" because-- NO!!! That Is Not How That Went.
the whole point of megamind isn't that he is some misunderstood hero, it's that he is The Villain!!! he revels in ruining people's day! he wants to be feared! he wants to cause chaos and mayhem and yeah it's all tied up in childhood trauma of his good intentions being continually and willfully misunderstood, yeah he made his choice to be the bad guy thinking there was no other thing he could be, but it was still very much a choice!
megamind still very much made that paint bomb and built that robot suit and kidnapped that reporter. stole that art. stole that money. terrified those people. rejoiced when he thought he'd finally managed to kill his rival. when he's depressed minion suggests a kidnapping to cheer him up and for a few seconds it works. the slave army segment on tv. like yeah it's all played in a very humorous way but megamind is not a good person, and that's the point.
it all comes down to that conversation with roxanne in the rain. because he's been lying to her. he's been lying to her for months and was fully prepared to keep on lying to her as long as he could get away with it, and she calls him out on it. it doesn't matter if he's nice, it doesn't matter if he makes her laugh, what matters is that he tricked her and lied to her and would have continued to do so. what matters is that he killed a man and terrorized a city. what matters is his actions.
when he apologizes to minion, he says, "please don't make this city pay for my wrongdoings." megamind has finally come to terms with the fact that he did some fucked up shit, and he is ready to take responsibility. for his whole life this prison has been home, but it's also still very much a prison. he is locked up to keep people safe. he is locked up as a punishment for his behavior. and when he is finally ready to put aside his villainy and become the hero the city needs, he leaves the prison for the last time.
no matter why he made the decisions he made, he still made them. he still hurt people. he has to make the choice to stop hurting people and start helping them. he has to make the choice to stop being the villain and start being the hero. it's isn't about the audience's perception of him shifting it's about megamind realizing he's gone too far and now he has to become a hero to save his city from the consequences of his own villainy.