anakin was an emotional child in a order that taught emotional suppression.
it's telling that he did this with padme and not obi-wan. like he felt she was the only person who could understand his feelings and not judge him or belittle him for just having emotions.
which in turn lead him to the dark side more than people realize.
in ROTS, anakin defeats dooku and has him dead to rights. palps tells him to kill him but anakin initially refuses as it's not the jedi way. only after palps pushes him does he do the deed but he takes no pleasure in it. just some shame that he didn't follow the rules of the jedi.
fast forward to the fight with palps. mace has him dead to rights. anakin tells him not to kill him, both because he could help save padme and because it's not the jedi way. but then mace doesn't listen to him, insisting that he had to die. now from our point of view, mace was right. palps was far too powerful and influential to be taken alive. but from anakin's POV, it makes mace, and by extension the council, look like massive hypocrites. that they only follow the codes when it pleases them. and here was mace, the guy who never liked anakin to begin with and respesented everything anakin hated about the jedi, doing as he pleased. so pushed to his emotional limits, he did what he had to do.