Remember: if-statements only apply to the things inside them. So the line
end the story saying "[if the player does not wear the hat]You don't have a hat!"
is actually equivalent to
if the player does not wear the hat:
end the story saying "You don't have a hat!";
otherwise:
end the story saying ""
This is probably not what you want. You should replace those two rules with something like this:
Instead of going north from the Counter:
if the player wears the hat:
end the story saying "You have a hat!";
otherwise:
end the story saying "You don't have a hat!"
Or, equivalently (assuming neither ending is “final”)
Instead of going north from the Counter:
end the story saying "You are[if the player does not wear the hat]n't wearing a hat[else] properly dressed[end if]!"