Perhaps Mario first picked up his possession cap in one of Princess Peach's paintings?
Super Mario Odyssey has come up with a creative gimmick for the series by letting Mario possess anything - from NPCs, to enemies, to inanimate objects. But who says these mechanics were only possible on the Nintendo Switch? At least one enterprising modder was able to bring the possession cap to Super Mario 64, letting you take control of any object in the classic N64 environments.
While the possession (or rather, capture) elements aren't exactly polished, it works precisely the same as Odyssey. The attached video shows Mario flinging the cap about on Bob-omb's Battlefield, taking control of enemies, moving platforms, and even the protective cover to the Pink Bob-omb cannon. Sadly, we don't get a chance to see Mario use the cap on the Chain Chomp, but I imagine it would work just as effectively.
Sadly, while this version isn't playable (not legally anyway), you can take heart in knowing that Super Mario Odyssey will arrive on Nintendo Switch this October 27, 2017.