The episode "Can You Spare a Dime?" of SpongeBob SquarePants features Squidward quitting his job over a misunderstanding. When he ends up losing his house, SpongeBob selflessly takes him into his own home, and takes care of him. Squidward "thanks" him by becoming a freeloader, forcing SpongeBob to wait on him hand and foot, and throwing violent tantrums when he does not comply to Squidward's whims to every detail.
In "Porous Pockets", SpongeBob gets his hands on a fortune and generously buys ice cream for a stranger. Cue an enormous crowd of moochers skulking for free money until SpongeBob is bone dry.
A similar thing happens in "The Sponge Who Could Fly" where SpongeBob uses his flying pants to perform heroic deeds but the citizens of Bikini Bottom quickly become dependent on him for more or less everything so when he tries to escape they hunt him down because he "owes" them favors. These being the same citizens who ridiculed him for wanting to fly and formed an angry mob against him for having dreams earlier in the episode.
Happens to Zuko in a season 2 episode of Avatar: The Last Airbender when a village he saves from corrupt guards instantly turns on him because he was a Firebender.note And not just any Firebender. Prince Zuko, son of Fire Lord Ozai.
Three years earlier, when he spoke out against sacrificing newly recruited soldiers, Zuko got burned and banished by his father for it.
Ironically, in the final episode, Zuko actually thanked his father for it, since it led to his eventual Heel–Face Turn. Ozai likely wished he killed Zuko when he had the chance.
And Haru in season 1, who saved an old guy from a cave using Earthbending, but he turned Haru in to the Fire Nation soldiers.
This trope comes into effect in Fillmore!, near the end of "Two Wheels, Full Throttle, No Brakes". Fillmore was able to catch the culprit behind the scooter thefts. And his reward? He and Ingrid get slammed with desk duty until further notice. Why? Because Fillmore used Vallejo's bike to catch him, but it got smashed in the process. Fillmore explains that his bike was sacrificed for the greater good, but Vallejo's not having any of it.
On The Simpsons, Homer's mom became a runaway outlaw once she helped Mr. Burns after a bunch of hippies walked all over him. Even the producers lampshaded this in the commentary by saying that "Never act in kindness" was the moral.
Frank Grimes saves Homer from drinking a vial of acid, but smashes it against a wall. Burns chews out Grimes for wasting his precious acid and damaging the wall (Though who keeps acid in the dining area?), and even worse, had Frank not saved Homer, Homer might have died.
Also, Ned Flanders attempted to be kind by allowing two female college students to stay while they sleep and work on their studies. How do they repay him? By using the room he rented out to them as a studio for a softcore video site, sexy slumber party. Similarly in the same episode, Flanders attempts to be a good neighbor to his town and to Homer, but his attempts at good deeds are repaid by Homer leaking the video to the whole town, as well as the town cheering on the girls when Ned evicts them, and mocking him behind their backs.
And speaking of Ned Flanders, there's his "Reason You Suck" Speech to all of Springfield... except this was after the townspeople had selflessly tried to help rebuild his house. It ended in failure, but they did try, which is lampshaded and derided in the speech itself by Ned.
Bart, as the Shadow Knight, decides to do a good deed and sacrifice two-thirds of his life to resurrect an elf, Marge, although Marge tends to Bart, the same can't be said for the rest of the characters, deciding that his action meant he was easy pickings, and decided to take advantage of his weakened state by brutally slaughtering him. While Bart lost interest on the game anyway, Marge decided to avenge him.
When Homer became smart, he sent a safety report to the Nuclear Regulatory Commission. This led to all the SNPP workers losing their jobs.
During the episode about Jessica Lovejoy, Bart realized she's even more mischievous than he is, after he witnessed her steal the money out of the church collection plate. After he refused to go along with it, she leaves right when the members of the church noticed Bart with the empty collection plate. If not for Lisa's determination to defend her brother, Bart would have been run out of Springfield.
During a Treehouse of Horror, there was a story where Lisa helped a dolphin to escape back to sea. Said dolphin eventually lead other dolphins in taking the surface away from mankind. (They claim they used to live at the surface before being ran out of it by humans) Also, when Lisa noticed a dolphin with a nose stuck at a can ring, she helped it and it bit her hand hard. Lisa almost snaps and curses at him before Homer sucker punches it.
In "The Old Man and the Lisa", Lisa decides to help Mr. Burns after he goes broke on the advice of yes men. Lisa encourages him to become an honest business man and help people by starting a recycling company. But Burns' morality is so twisted, he gets the idea to help people by recycling sea animals into a slurry, to Lisa's utter horror.
Homer: Well Lisa, you've learned your lesson. Never help anyone.
Dib from Invader Zim suffers this constantly. Perhaps most obvious in "Room With a Moose," where the kids mock, wedgy and ostracize him as he tries to warn them about Zim, and then has to use their cruel treatment of him to save their lives. He even considered dooming them despite knowing he'd doom himself as well.
Buttons from Animaniacs embodies this trope. Every episode has Mindy getting out of her harness or crib etc, and causing Buttons to go and save her, going through absolute hell in the process. And at the end of every short the parents scolds him every time. Well, at least Mindy comforts him. He gets praised and rewarded for his dedication and loyalty in The Movie, however.
Most of the time, when Disney's Aladdin does a good deed, it turns out okay. However, in "The Citadel", the introductory episode for Knight of CerebusEvil Sorcerer Mozenrath, when Aladdin tries to save a woman and her baby from a monster, they're actually illusions designed to lure Aladdin in so that Mozenrath can try to talk him into capturing another monster. Aladdin refuses, because Mozenrath is Obviously Evil, but then gets sent to Mozenrath's castle anyway. He finally catches the creature, and then decides to do a good deed for it, letting it back into its own world rather than leaving it as a slave to Mozenrath. Essentially, good deeds were in this case punished with the bitter enmity of the series' most powerful villain.
In another episode, thanks to Iago getting a bump on the head, he experienced an uncharacteristic amount of selflessness and charitability by giving away a lot of things, including Genie's lamp. Unfortunately, this characteristic ended up causing more harm than good not only to him, but to everyone near him as well.
In the Batman: The Animated Series episode "The Mechanic", this trope is part of how Earl Cooper became the Batmobile's mechanic. Years ago, Cooper worked for a car company and noticed a fatal flaw in one of their car designs. The CEO refused to change it, and had some goons sent to silence Cooper, but Batman saved him. Unfortunately, this gave him a reputation as a whistle-blower, and as such Cooper couldn't find another job until Batman hired him for his car.
Batman always follows through with one rule when dealing with the Joker, sometimes even saving the latter. Come Batman Beyond: Return of the Joker, and the flashback that ensued, Batman most likely will wish he hadn't followed that rule knowing that Batman was in a way responsible for the Joker's most horrific (as well as final) act.
In the Tom and Jerry cartoon "Buddies Thicker than Water", Tom is out in the snow and begs Jerry to help him. Jerry lets Tom into the penthouse apartment he lives in, warms Tom up, and gives him a hot meal. When the owner returns home and attempts to throw Tom out, he ingratiates himself to her by grabbing Jerry and throwing him out in the snow. Of course, this gives Jerry the justification he needs to scare Tom out of the house again and then ignore a second plea for help at the end of the cartoon.
Granted, this was also recycled with the roles reversed in "Snowbody Loves Me". After a frozen Jerry knocks on Tom's door, Tom opens it, after which Jerry sneaks in and locks Tom out in the cold. Similarly an indignant Tom manages to get back in and kick Jerry out, though suffers a Jerkass Realization and lets him back in, this time with more upbeat results.
X-Men: Evolution has the end of season 2: The Sentinel is released, and by sticking around to fight it, the mutants are forced to reveal themselves, causing mass witch hunting and prejudice against them, even after they prove that they weren't responsible for the Sentinel and were the good guys there. Then, as the end of the series proves, the same thing happens when they defeat Apocalypse, and it's revealed that mutant hatred will continue, more, and more powerful, sentinels will be built and used, one of their closest allies will be consumed by darkness, and at least two of them will be noticeably missing in the future line up. Hey, at least Magneto will become good and the Brotherhood will join SHIELD, but since it was SHIELD who were placed in charge of Sentinel production in the present, that might not be a good thing.
In the Popeye cartoon "A Dream Walking", Popeye saves Olive from sleepwalking at a construction site and brings her back to her bedroom. However, when she wakes up, she thinks Popeye is being a Peeping Tom and throws stuff at him.
In "Little Swee'pea", Popeye saves Swee'pea from the zoo animals and bring him home safely. Popeye decides to entertain him with a toy monkey, which scares him, causing Olive to think he's scaring Swee'Pea and promptly cleans Popeye's clock.
"No ifs, ands or maybes, I'll never has babies/I'm Popeye the Sailor Man!" (toot-toot)
American Dad! had an episode, "The Full Cognitive Redaction of Avery Bullock by the Coward Stan Smith," wherein the CIA believes that Avery has dementia and orders Stan to have him mind-wiped, which would make him a vegetable. Stan rebels and saves Avery, only to find his behavior becoming stranger and more nonsensical until he steals a nuclear submarine. Eventually, Stan comes to terms with Avery's dementia and tries to euthanize him with a bullet to the head. However, Stan's bullet hits and destroys a mind-scrambling chip, planted by another CIA agent as retribution for Avery's bullying. Instead of thanking Stan for saving his life and sanity, Avery punishes Stan with a demotion because he didn't follow orders.
The Fairly OddParents!: Timmy Turner seems to run into this trope a lot. It's most noticeable on the Christmas specials. He is usually in universe and by fans called out on his selfishness and unwillingness to share. However, in the movie A Fairly Odd Christmas as well as Merry Wishmas, Timmy is condemned for being generous because he's "muscling in" on Santa Claus' territory.
It's pretty common for people to find the titular Kevin Spencer and choose to look past his violence and theft and try to help him get on the right track. Because of thenature of this show, Kevin abuses their kindness and mistreats and steals from them. One episode had him build a friendship with the Widow Coulson, and even though he grew to care for her, he stole her medication.
In "The Nice Guy", Wander's kindness again backfires when his desire to be nice and helpful complicates a simple attempt to buy Sylvia a bottle of her favorite soda. He even ends up giving the last bottle of Thunder Blazz to a little girl... who ends up giving it to Sylvia herself.
Done infamously in the My Little Pony: Friendship Is Magic episode Princess Spike. While it's true he does do some selfish and thoughtless things when being put in Twilight Sparkle's leadership position, and thus deserves some of the flak, literally none of these things cause any problems. It's all the things he did with legitimately good intentions while trying to actually do things Twilight Sparkle would do and an overabundance of Dragon Sneeze Plants (guess what they do) that cause all the problems, meaning if he hadn't done anything wrong he still would have been dragged through the wringer. The resulting Broken Aesop didn't sit well with many fans and is a major reason it appears so frequently on "Worst Episode lists".
Discussed in the opening narration of Teenage Mutant Ninja Turtles (2003) episode "City at War, Part 2". According to Mikey, the Turtles thought they did the city a favor when they defeated the Shredder at the end of "Secret Origins, Part 3". However, the resulting Evil Power Vacuum has created a gang war between the Purple Dragons, Foot remnants, and mobsters that threatens to destroy New York. Leo tries to fix things, but his actions in fact trigger a huge battle that wrecks a city block.
Discussed in the Bob's Burgers episode Thelma and Louise Except Thelma Is Linda. Louise gets detention for pantsing a student, even though she only did it because said student was bullying another. She sees herself being punished as this trope, and the plot focuses on Linda busting her out of detention and trying to reward her to challenge this trope.