So Anakin simultaneously has a better moral compass than the Jedi but is also killing kids which make his moral compass even less than that of Mace Windu's. He also beheaded Count Dooku when he was incapacitated. And he really didn't care about the Jedi Code, he just wanted to save Palpatine because Palpatine said he could save Padma. When he chops off Mace's hand in anger he says "I need him!" not "This isn't right!"
Well I think you're touching on the moral complexity of Anakin. He's a LAYERED character rather than a simple one.
Also, I'm glad you touch on him killing Count Dooku. Let's get into that. . .
When he has Count Dooku on his knees, does he kill him of his own volition? No. It's Palpatine who order's Dooku's execution. And does Anakin immediately comply? Again, no. He says that Dooku should stand trial.
What are Palpatine's words? "He is too dangerous to allow to live."
Anakin then kills Dooku but is clearly fucked up about it.
Let's flash forward to Mace Windu and Palpatine. . .
When Windu has Palpatine cornered, what are his words? He echoes Palpatine's own words: "He is too dangerous to allow to live."
Anakin sees Mace Windu betray the Jedi code. He then realizes the corruption of the Jedi order.
And don't forget that from Anakin's perspective, the Jedi have been opposing him from Day 1. They didn't want to train him . . . they refused to make him a master . . . they forced him to hide his love for Padme.
This is enough for Anakin to cross over to the Dark Side. The Jedi are now his enemy. And this is why the younglings must die, so that they cannot carry forward the teachings of the Jedi.