From the Super Mario Wiki
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 had ordered numerous Unzappable Hats from the Gangster Supply Store, and ordered Mouser, Koopa Troopa and Tryclyde to try one (three in Tryclyde's case) on. He then shot them with bullets from a Snifit, much to their fright, but due to the power of the Unzappable Hats, their bodies were unharmed.
Wearing the Unzappable Hats, Al Koopone and the Koopa Pack went to rob the First Mushroom Bank. Mario and his friends attempted to stop them with Vegetables, but stood no chance against the Koopa Pack while they were wearing their Unzappable Hats.
Later on, Mario's group made their way to the Koopa Klub and stole the Unzappable Hats that were being stored in the coat check room for themselves. Confronting Al Koopone for a second time, Mario and his friends were invulnerable to the Koopa Pack's Snifits now that they were wearing the Unzappable Hats. Because of the Unzappable Hats, Mario's group eventually managed to defeat the Koopa Pack and were able to chase Al Koopone out of Crime Land.