Somewhat enhanced in Power Rangers and other Tokusatsu series, where if a character covered in filth transforms, they'll be squeaky clean when they de-morph. Apparently the Morphing Grid does sheets, too.
Mostly averted in Star Trek: Deep Space Nine — the shapeshifter Odo forms clothes out of his own substance, but seems to have a Magic Combadge. The Expanded Universe either implies that he'd usually put the badge on the inside of whatever he turned into (since he didn't need to actually make organs and so on). Which doesn't explain where it goes when he turns into things like puddles of water.
Also played straight in the Star Trek: Voyager episode "Tuvix". An alien plant gets mixed up in the transporter beam and merges Neelix and Tuvok into one new being, even merging Tuvok's uniform and Neelix's Talaxian clothes into a Starfleet uniform made of Talaxian-patterned fabric. Later when the procedure is reversed, Tuvix is separated back into Tuvok and Neelix, each of whom somehow have their own copy of Tuvix's uniform.
Justified in the fact that the clothes Tuvix had been wearing when he was split apart was not the merged Starfleet-Talaxian outfit but instead a regular Starfleet uniform. At the very least, the Magic Pants are consistent.
Very present in the Animorphs TV series. In the books, clothing had to be nearly skin-tight to morph with you.
Present in every episode of Manimal where Dr. Jonathan Crane (a.k.a. Manimal) transforms into a panther, hawk, dolphin, cat, or whatever animal-du-jour. In the pilot he transforms to a panther while wearing a tux, and the tux is nowhere to be seen. Upon retransformation to a human he is still wearing the same tux. This is repeated throughout. Sometime we even see the clothes he wears being torn up by the transformation.
Played straight in the Season 6 episode "Villains": when Willow kills Warren, she rips his skin from his body, but leaves his pants on.
Averted in the Season 2 episode "Bewitched, Bothered and Bewildered": Buffy loses her clothes when she is turned into a rat, leading to an embarrassing moment when the spell wears off and she turns back again. Not that she was wearing pants to start with.
Also averted with Oz. He is very much naked after a full moon night, even though his werewolf form isn't even that much bigger than his human form.
In the Season 3 episode "Beauty and the Beasts" Angel somehow gains pants after coming back from the dead nude, despite having regressed to an animalistic state and living in the wilderness.
Present in Season 3 of Heroes: when Sylar is zapped multiple times by Elle, his shirt burns off him but his trousers appear completely undamaged.
Also in Season 1, when Nathan flies at a supersonic speed, his pants magically stay intact.
Averted in The Secret World of Alex Mack; Alex's first attempt at morphing into silver goo winds up with Alex naked and hiding behind a washing machine. The second time, she manages to morph her clothes with her.
Averted in Woof — very much so — Eric Banks/Rex Thomas lost his clothes every transformation.
Averted in Being Human. Poor George gets no Magic Pants when he transforms into a werewolf.
Averted in True Blood when Sam the shape-shifter changes back into human, he has to find things to cover up with and get people to bring him clothes.
Piper is wholly naked after she transforms back to human form after being a Wendigo. Same goes for Phoebe after she changes from mermaid back to human.
On the other hand, Prue is wearing the same clothes when she turns back from a being a dog to human. Same for all three sisters are also wearing clothes after they change back from being beasts during a blue moon.
Invoked in The Vampire Diaries where Tyler removes most of his clothing in preparation for his transformation into a werewolf, but keeps his pants on in case "it's like the Hulk". It's not.
Played with on The Young Ones when Neil loses his temper and transforms into The Incredible Hippie, complete with sleeve-splitting shots and his pants bursting open only from the knees down. Then it turns out to be a fantasy-sequence in which he only imagined he'd transformed... except his clothes are still torn.
An extreme example of Magic Pants is in Legend of the Seeker, Season 1, Episode 19 "Cursed". There is a scene where a naked kalthrop (i.e. werewolf) is killed, and then turns back its human form, with the Sword of Truth protruding from its chest. The problem...the now unmutated king is still wearing the clothes we saw before. A second scene shows a battle where another kalthrop, again naked, is finished fighting, goes into a corner, and (hidden from the camera) turns back into queen Corah who not only is fully clothed as we saw before, but has the crown on her head, like nothing happened. This got my attention right away, no Fridge Logic required! It just seemed lazy to me.
On Teen Wolf the twin Alpha werewolves Aiden and Ethan can do a Fusion Dance to merge into a giant Super-Alpha. For some reason they feel the need to strip all the clothes off of their upper bodies before merging. But their pants and shoes merge when they do.