Throughout their respective trilogies, Anakin and Luke are both trained to become Jedi. The Jedi Order preaches an ideal of dispassionate compassion, an avoidance of attachment, and the prioritization of the will of the Force over personal concerns.
The two of them end up in very different places at the end of their training, despite both having Obi-Wan and Yoda as teachers. Anakin is left unconvinced by the Jedi teachings, and Palpatine is able to use this as a crowbar to turn Anakin to the Dark Side. Luke, on the other hand, turns away from the version of Jedi doctrine that Obi-Wan and Yoda have forced on him, only to declare ‘I am a Jedi, like my father before me’.
Anakin’s Jedi training didn’t work well with his temperament. He spent the first decade of his life as a slave, accustomed to following orders and calling someone ‘master’ for the sake of not endangering himself. The Jedi Order isn’t much of a change in that respect – it’s still a lot of ‘Yes, master’ and having to rein himself in to avoid trouble.
The trouble is that it really doesn’t work well for Anakin. This is a youth with a lot of fears and concerns, and no one he can count on to help address them. He struggles to maintain the lack of attachments that the Jedi are so fond of, and the advice he’s given doesn’t help him. He’s also treated with suspicion by the Jedi Order, and that really doesn’t help. Qui-Gon was impressed by his Force sensitivity, and Anakin knows that. And yet, the Jedi don’t seem to accept that he is a gifted child. That breeds resentment.
The Jedi Order is also Anakin’s only social circle after he leaves Tatooine. Padme is the only person he’s close to who isn’t part of the Order, and she trusts them in a way he doesn’t. She supports Obi-Wan’s disapproval (’all mentors have a way of seeing more of our faults than we would like’), leaving Anakin alone with his distrust and concerns about the Order.
He also betrays the ideals of the Order by killing the Tusken Raiders who killed his mother and marrying Padme, so he really doesn’t have much cause to think the Jedi Order will support him. And so he falls back on Palpatine, who’s selling safety, false as it may be. I’ll refrain from the political commentary that comes to mind there.
And so we come to Luke, several years later. The Jedi Order has collapsed, and its greatest failure is one of the most powerful figures in the Empire. Luke’s fairly sure that being a Jedi is a good thing, judging by his keenness to become one. And it’s motivated by the fact that his father was a Jedi, that’s quite explicitly stated. Yoda is not impressed.
Luke is told the same things his father was told. Trust the Force, don’t let attachments get in the way of your final goal (that’d be the warning not to go to Bespin), be wary of emotion, the Sith are your enemy and must be destroyed. He’s set up to be a weapon against the Empire, despite his compassion and desire to save his father. And being that weapon relies on complying to the old Jedi code – no attachments, no emotion. Without those parts of the code, Luke’s hardly going to be able to kill his own father the way Yoda and Obi-Wan both expect him to.
Let’s see… Luke goes to Bespin anyway, decides not to kill Vader, and completely fails to let go of the attachment to his father. And somehow that ends up both saving his life and redeeming Anakin. Even though Luke calls himself a Jedi. So what did Luke have in his life that Anakin didn’t?
He had people who were out of the loop. Han calls it luck. He may not be right about that, but more importantly perhaps, Obi-Wan’s word is not the only one Luke has when it comes to the Force and the Jedi. Leia refers to Luke’s force sensitivity as ‘a power I don’t understand and could never have’, if in error. She’s impressed by it.
Luke doesn’t have the seething resentment that Anakin did. The Jedi Order hasn’t failed Luke the way it did his father. Luke certainly does have cause to resent at least two Jedi, but he has a life outside of that Jedi box. And that’s important, because the Jedi he knows aren’t actually that good to him.
The Jedi failed them both, but while Anakin only had a Sith Lord to fall back on, Luke had a safer place to go. He had the input from outside necessary to fix a broken system.