From the Super Mario Wiki, the Mario encyclopedia
An Unzappable Hat is a magical, gangster-styled hat that makes the wearer invulnerable to all outside attacks. Several variations of the hat exist, but they all have the same effect. The origin of the Unzappable Hat is a mystery, except that they are apparently sold by the Gangster Supply Store in Crime Land. Despite their effectiveness, Unzappable Hats were only ever seen in The Super Mario Bros. Super Show episode "The Unzappables".
Al Koopone orders numerous Unzappable Hats from the Gangster Supply Store, and orders Mouser, Koopa Troopa and Tryclyde to try one (three in Tryclyde's case) on. He then shoots them with bullets from a Snifit, much to their fright, but due to the power of the Unzappable Hats, their bodies are unharmed.
Wearing the Unzappable Hats, Al Koopone and the Koopa Pack go to rob the First Mushroom Bank. Mario and his friends attempt to stop them with Vegetables, but stand no chance against the Koopa Pack while they are wearing their Unzappable Hats.
Later on, Mario's group make their way to the Koopa Klub and steal the Unzappable Hats that are being stored in the coat check room for themselves. Confronting Al Koopone for a second time, Mario and his friends are invulnerable to the Koopa Pack's Snifits now that they are wearing the Unzappable Hats. Because of the Unzappable Hats, Mario's group eventually manages to defeat the Koopa Pack and are able to chase Al Koopone out of Crime Land.