On Halloween, there's a chance of mobs spawning with a carved pumpkin equipped as a headgear. They can also drop it when killed by the player, but the chances are low.
Uses of carved pumpkins in Minecraft
1) Creating golems
One of the most mysterious features of Minecraft is being able to create mobs by playing certain blocks in the correct orientation. Using carved pumpkins, players can spawn two different mobs: iron golems and snow golems.
Iron golems are neutral mobs that spawn naturally in villages to protect the villagers against hostile mobs. They will only attack players if they are provoked. To spawn an iron golem, players need four iron blocks and one carved pumpkin. They need to place the iron blocks in a T shape and then put the carved pumpkin on top of the middle block.
Snow golems are a utility mob that helps in defending against other mobs. To spawn them, players need to place two snow blocks vertically on the ground and place the carved pumpkin on top. It is recommended not to create them in hot biomes as they will start melting.
Like a helmet or mob head, carved pumpkins can be used as headgear in Minecraft. Players can also use it as a mask so that they do not provoke endermen by looking in their eyes.
This can be helpful when players are adventuring in the End. The only downside is that a pattern appears on the player's screen. However, players can switch to third person or F1 mode to get rid of it.
3) Jack o'Lantern
Jack O'Lanterns is the only item that can be crafted using a carved pumpkin in Minecraft. It is a block that can be used as a light source. Players can also use them instead of carved pumpkins to build golems. It can be crafted by placing a carved pumpkin on top of a torch in the crafting grid.