Ruth Johnston you can see the story in the numbers and the text:
in the primary the Democrats were cocky
here you had an incumbent who always won by a large margin
but the upstart probably put on a fierce campaign and drummed up a lot of votes from non voters.
in the general election, which is always better attended than primaries, The majority of people knew that they had to write instead of checking a box
The mayor of a town is a much more personal thing than president
I am from a very small town in New Jersey and I never really knew the party of who the mayor was. it was usually Republican but sometimes Democrat. I just voted for who I liked
actually I still do.