Saving it for later?
Squirrels gather their nuts and hide them for a cold day, hamsters and chipmunks store food in their cheeks for later in case they can’t find any more. The animal kingdom has many clever and wonderful ways of making sure that they can get food when they need it. Perhaps the owner of this gum was doing a similar thing.
Which would be fine if it was his hat. As it is, this is a hat sitting on a shelf in a store waiting for someone to buy it. Not that they’re going to want it now. Perhaps that was the gum owner’s plan. Stick the gum there, go shopping elsewhere, and come back to purchase it, safe in the knowledge that no one else would pick up a hat with gum stuck to it.