Fire Imps require a target space of at least four vertical air spaces and three horizontal air spaces to teleport into a location. Despite this, they only need three vertical air spaces and two horizontal ones to spawn.
The Fire Imps dropping the Plumber's Hat may be a reference to Mario's ability to shoot fireballs when getting a Flower Power-Up, similary to the Burning Spheres that Fire Imps shoot. This is further proven by the Obsidian Rose that they drop, which references the Flower Power-Up.
The Bestiary entry for the Fire Imp: "A lesser demon imbued with hell magic. Capable of teleporting and hurling phantom fireballs towards their foes."