It looks like you can randomly equip a hat at the start of each level after level 1. Sometime it won't equip a hat as a blank is part of the randomness.