I have never been able to understand the rules of Mjolnir. Like, what exactly makes a person "worthy"? Is it honor? goodheart? bravery?
Maybe because they were in a dire moment of a decisive fight that meant the life or death of everything, and out of all people Cap was the best suited to wield the Mjolnir (considering Thor already had the Stormbreaker and had his ass beat up), so the hammer kind of made an exception for him at that moment because it was necessary.