When another character does something heroic, a character pretends that they're the one that did so. Apparently they love the idea of fame and fortune. Never mind that fame comes with a price.
Expect an egotistical character to try doing this, especially if they can't fathom how somebody they considered to be inferior to themselves managed to pull off something that they could not.
In the real world, doing so is considered plagiarism, which of course can get you into a lot of trouble.
The Simpsons: After Homer tells Moe about the Flaming Homer drink he invented, Moe attempts to take credit for it, referring to it as the Flaming Moe. As a result, his bar ends up becoming famous. This backfires on Moe though, since Homer happens to know the trade secret.
Dragon Quest XI: Prince Faris has the hero pretend to be him for a horseback race as well as the capture of a dangerous beast, in exchange for a Yggdrasil tree branch. However, he has a Freudian Escuse. People simply expect too much from him as Prince of Gallopolis. Having said that, he eventually DOES something heroic by himself, which is impressive indeed.
Harry Potter: Gilderoy Lockhart is so narcissistic that he has stolen the achievements from wizards who have done astonishing things and used charms to erase their memories so that they couldn't testify against him. This backfires when he ends up using a broken wand to try to erase Harry and Ron's memories and he ends up falling victim to his own charm.
Mario and Luigi: Partners In Time: After Mario and Luigi rescue the Yoshis from Yoob, Baby Bowser attempts to portray himself as the hero for all the glory that comes with...as well as the Yoshi cookies. However, Toadbert explains that it was Mario and Luigi who rescued them (along with their baby selves) and that Baby Bowser was in an egg the whole time.
Persona 5: One of the targets of the Phantom Thieves is an artist who takes credit for other people's works...never mind that other people end up suffering for it. In fact, his best piece of art was in fact stolen from Yusuke's mother, and he murdered her through inaction so he could make off with it.
Dragonslayer: After the dragon is successfully slain, the king attempts to take credit for it. Of course, it's actually rather believable since his own daughter sacrificed herself to the dragon.
Coco: Ernesto La Cruz is revealed to have not written his own songs. He in fact stole them from his friend and his partner Hector. How did he get away with it for so long? He poisoned him!