Cap was always worthy of wielding Mjolnir. Period. He chose not to do it in AoU because that's totally a Cap thing to do. The enchantment on Mjolnir doesn't say, "if you're kind of worthy you can budge it a little." Either you can move it, or you can't move it at all. Hell, Thor shows a string of people failing to budge it, and if there's a "kind of worthy" rule out there, no doubt millions of people would be able to budge it. Whedon isn't some noob to comics, and what he put in AoU was clearly a wink and a nod to the fans that knew there'd be a payoff later on down the road. I remember leaving that movie and talking with my wife about it, and we were both like, "Steve could totally life Mjolnir, but didn't to spare Thor's pride."
Thor's "I knew it!" in Endgame seals it that he always suspected Steve could wield it.
Much like the Avengers Assemble line teased in AoU, Whedon knew it'd be used in a more fitting scenario later on, even if he didn't plan on setting up the moments in Endgame specifically.