How did Captain America, Steve Rogers,
become worthy to lift and use Mjölnir and Stormbreaker
effectively in Avengers: Endgame?
Steve has always been worthy to lift Mjölnir as we saw in Avengers: Age of Ultron he was able to move it slightly. Why he could only move it slightly is speculation but the two main theories are:
His intentions at the time weren't worthy, he was showing off.
He stopped moving it because he didn't want to show Thor up in a light hearted game.
Thor even comments something to the effect of Steve being worthy all the time with:
I knew it!
When Steve starts using Mjölnir.
He was always worthy for the same reason as Thor became worthy of Mjölnir in Thor...
Steve put his life on the line to protect the universe and was not going to give up when all hope was pretty much lost. He's always done this in the past as well and that is why he has always been worthy. However, he hasn't tried to wield Mjölnir before now except in Avengers: Age of Ultron where his intentions weren't exactly worthy as mentioned above.
As I said above this is similar to Thor in Thor when he gives up his life to save those on Earth and becomes worthy of Mjölnir once again.
THOR: Brother... for whatever I have done to wrong you, whatever I have done to lead you to do this, I am sorry. But these people have done nothing to you. They are innocents.
I believe there is something in the comics to the effect of people who are only just not worthy to use it can "level up" to use Mjölnir in the time of need and so this could also have affected it here but Steve also wields Mjölnir at the end of the film to take it back so I don't think it applies here.
The Russos, the directors of the film, answered this on Twitter
Mjolnir requires worthiness, not Stormbreaker. - Russo Brothers #InfinityWar #VuduViewingParty
In fact, this is pretty definitively proven in Endgame, when Thanos himself briefly wields Stormbreaker against Thor (assuming Thanos wouldn't be regarded as worthy nonetheless).
One fan theory I read was that as Captain didn't tell Tony about Bucky taking out his parents. That was his spot of unworthiness. After the winter soldier events, this was over and he was worthy again.