There is a bit of a history behind this...

The Guardian cartoonist Steve Bell used the allegation by Alastair Campbell that he had observed (John) Major tucking his shirt into his underpants to caricature him wearing his pants outside his trousers, as a pale grey echo of both Superman and Supermac, a parody of Harold Macmillan

Wikipedia

["Super-Mac" was from a 1958 cartoon image of Harold Macmillan, and became an enduring nickname for him. ]

An example of a Steve Bell political cartoon lampooning John Major...

enter image description here

The trope was taken up in the Woody Allen movie Bananas (1971), in which an increasingly insane revolutionary leader overthrows a typical banana republic and begins to issue a number of strange executive actions. One of these is that underwear must be changed 7 times daily, and in order to facilitate checking compliance with this dictum the underwear must be worn on the outside.


On the possible origin of the trope:

From Piperson at The Great Comic Book Heroes

Men in Tights - a history

When Superman first hit the scene with his blue and red tights it created a shockwave around the country that it hit off the whole superhero craze that is going on stronger than ever today with blockbuster movies like Batman and the Avengers. Before that no one had ever seen a hero in tights and cape. Where did they get the idea from?

enter image description here

Siegel and Shuster created a character called Superman in 1933 though it bore very little resemblance to the Superman we know. He had mental powers but had normal strength. A year later they would re-envision him into a super crime fighter.

From Wikipedia on the creation of Superman - “The pair re-envisioned the character, who became more of a hero in the mythic tradition, inspired by such characters as Samson and Hercules, who would right the wrongs of Siegel and Shuster's times, fighting for social justice and against tyranny. It was at this stage the costume was introduced, Siegel later recalling that they created a "kind of costume and let's give him a big S on his chest, and a cape, make him as colorful as we can and as distinctive as we can."

"The design was based in part on the costumes worn by characters in outer space settings published in pulp magazines, as well as comic strips such as Flash Gordon, [Doctor Occult, the Phantom,] and also partly suggested by the traditional circus strong-man outfit, which comprised a pair of shorts worn over a contrasting bodysuit."

Around this same time Alex Raymond's Flash Gordon hit the funny papers. He would often wear tights and cape so it's not very far fetched to imagine that this very popular strip was a big inspiration for the creation of Superman.