I think a huge part of Anakin's conflict - and thus his "erratic" behavior - comes from the dichotomy of the teaching he was getting: Obi-Wan, Yoda, Mace Windu, etc. were teaching him to control his emotions and basically surrender to the Force, while Sidious was teaching him (however subtly) to harness his emotions and bend the Force to his will. Consider the following:
Yoda, in an attempt to teach Anakin about the Jedi view of death and to leave behind personal attachments has this conversation:
Yoda: Premonitions, premonitions. These visions you have...
Anakin Skywalker: They are of pain, suffering. Death.
Yoda: Yourself you speak of, or someone you know?
Anakin Skywalker: Someone.
Yoda: Close to you?
Anakin Skywalker: Yes.
Yoda: Careful you must be when sensing the future Anakin. The fear of loss is a path to the dark side.
Anakin Skywalker: I won't let these visions come true, Master Yoda.
Yoda: Death is a natural part of life. Rejoice for those around you who transform into the Force. Mourn them do not. Miss them do not. Attachment leads to jealousy. The shadow of greed that is.
Anakin Skywalker: What must I do, Master Yoda?
Yoda: Train yourself to let go... of everything you fear to lose.
Then, Anakin has the following conversation with Chancellor Palpatine:
Palpatine: Did you ever hear the Tragedy of Darth Plagueis the Wise?
Palpatine: I thought not. It's not a story the Jedi would tell you. It's a Sith legend. Darth Plagueis was a Dark Lord of the Sith so powerful and so wise, he could use the Force to influence the midi-chlorians to create...life. He had such a knowledge of the Dark Side, he could even keep the ones he cared about...from dying.
Anakin: He could actually...save people from death?
Palpatine: The dark side of the Force is a pathway to many abilities some consider to be unnatural.
Anakin: What happened to him?
Palpatine: He became so powerful, the only thing he was afraid of was losing his power...which, eventually of course, he did. Unfortunately, he taught his apprentice everything he knew. Then his apprentice killed him in his sleep. Ironic. He could save others from death...but not himself.
Anakin: Is it possible to learn this power?
Palpatine: Not from a Jedi.
Now, I might argue that both of these "instructors" knew exactly what was on Anakin's heart and mind at the time of their conversations, and they were both trying to lead him to the understanding that they held, but these are two very different and conflicting lessons that Anakin must now reconcile for himself. Anakin has already proven through his actions that he is strong-willed and self-reliant - one of the dangers of being so powerful in the Force and knowing it. He says to Padme in Episode II:
Padme Amidala: You're not all-powerful, Ani.
Anakin Skywalker: Well, I should be! Someday I will be. I will be the most powerful Jedi ever. I promise you. I will even learn to stop people from dying! It's all Obi-Wan's fault! He's jealous! He's holding me back!
Anakin is an impetuous teenager, rebelling against his "strict parent" figure, Obi-Wan, who is doing everything he can to reign in the over-inflated ego of someone who is just learning to control and use the ability with which they have been gifted. Of course, Anakin doesn't see that, and, whether this is just an angry outburst, or it's what he truly believes, there's a part of him that longs to be free of the Jedi and all their "rules".
Add to this a "teacher" in the form of Palpatine who is feeding those longings and casting little "digs" to undermine the Jedi teachings every chance he gets, along with Anakin's apparent need to learn everything the hard way and "I'll do it myself" attitude. Now you have a kid who is careening down the highway at breakneck speeds, barely staying on the road because he keeps banging into the guardrails on the sides. Anytime the guardrails are missing, he starts to go off the road. He can and does "recover" and get back on that road many times, but it's just a matter of time before he loses control entirely... Darth Vader.