What's that hat?

Have you noticed these little hats and do you know what it is for? We are asking you!
Where have these little hats come from?