Pumpkins were associated with Halloween because pumpkins came around in fall during the harvest and so pumpkins started being carved to look like monsters for decoration.
Pumpkins were originally just craved with a small hole in the front and at the top just so a candle could be put in and lit so that the light shown through. The light was supposed to ward off evil because evil is dark and the opposite of dark is of course light.
The pumpkins are carved because of an Irish legend about a man named Jack. According to the story, Jack mistreated his wife and somehow tricked the devil too many times to save his soul. When Jack died, he wasn't allowed in heaven and the devil would not let him into hell because of all the tricks he played on him. So the devil threw Jack a hot coal so he could see his way around in the dark and Jack put it in a turnip he carved out. He then wandered the universe for eternity looking for a place to rest his soul. In Ireland people started puttingcarved turnips outside their doors to scare the ever wandering Jack away. And then when the Irish saw the pumpkins in America they started using those instead.
A light was lite inside of the pumpkin so that people's dead ansesters could find their way home on Halloween, the only day in the year that the dead all fully awake.