Most of them never had any guarantees they would be recorded in history - or that anybody would even know.
In 1773 the ship De Jonge Thomas was sunk in a storm outside Table Bay in Cape Town. A elderly farmer by the name of Wolraad Woltemade jumped on his horse and rode it into the sea and rescued two drowning sailors from the wreck, saving their lives. Then he went right back in and pulled out three more. He did this 7 more times - saving 14 stranger's lives.
He went in an 8th time - once more risking his life - but as he did so the wreck collapsed and no less than six sailors grabbed onto the horse. The horse, already exhausted, could not carry them all and they drowned along with Woltemade.
By all accounts - including what he told people before he went in - he acted out of pity. He had no way of knowing his actions would be remembered. He knew he was risking his life but he also believed he could succeed. Indeed he did, 7 times he succeeded.
Woltemade had no way of knowing he would go down in history, that in fact South Africa's highest civilian honour for heroism would be named after him - an honour which is only given post-mortem for people who died to save strangers. My own uncle was a recipient. He was working at a gas refinery in the 1970's - in appartheid South Africa when a leak sprung in a gas-line. A number of black workers were trapped inside the pipe. He went and pulled three of them out, then he went in again and pulled out more...and kept going until he himself was overwhelmed by the toxic gas and died.
This was a white man - an extremely rightwing one - in appartheid South Africa, who died to save poor black people's lives. Absolutely everything about his culture, upbringing, religion and politics told him that he was the superior human being - yet he died saving them.
To claim that these people - who were overcome with pity at the suffering of strangers and risked their lives fatally to try and save those strangers were acting out of a desire for glory is an insult to their memory.
Perhaps YOU are so big of an asshole that you could never comprehend a truly selfless act - but don't project your mental issues onto the world at last. Almost nobody else on earth is like that. The people who are always claim that everybody else is like that too. The same way rapists tend to think every other guy also does the things they do. Both are simply wrong about that. It's a story told to make themselves feel better about being assholes.
And that is what you call somebody who has no pity for the suffering of any person, even a stranger, an asshole. Not a typical human being. Not a representative sample. An asshole - and luckily, an extremely rare variety of asshole.