needle sizes are only a suggestion.
They are the size needle 1) the designer used (in many patterns) or
2) the size needle MOST knitters would use to get the gauge.
the GAUGE is what matters.
Gauge is a way of defining the size of the stitches.
think of tiles for a floor or wall (vinyl or ceramic, or what ever)
how many do you need? well if you tiles are 1 inch X 1 inch--thousands (you'd need 12 rows of 12 columns (144) to just cover 1 square foot!
but if your tiles are 4 X 4, you'd need 9 tiles (3x4=12) to cover 1 square foot.
(and if your tiles are 12 X 12, 1 tile per square foot!)
in knitting the needle and yarn work together to create the stitch, and the stitch size can (does!) change.
so to figure out if you have enough stitches. you need to do a gauge swatch and figure out, IF, with your needle and your yarn, you make stitches big enough to fit your... in this case, head.
hats USUALLY are slightly smaller than head (this is called negative ease) Loose (hat bigger than your head) fall off.
knitting stretches (but not infinately!) so if you gauge is close, it might be fine.. if not, you might want to get some more/different sized needles.. or add a few stitches to make the hat bigger.
(but adding stitches need to been done with planning.. when you come to the crown of the beanie, you might find that the planned decreases for shaping the hat require a specific number to work out neatly, and you'll have to plan how to return to original number of stitches!)
(i have needle in several different materials, and many different styles (straight, DPN, Circular) is sizes ranging from 000 to 15!)