Most people expected Hawaii to be the Republican state and Alaska to be the Democrat state at the time, and that was reasonable given that they only started shifting around the mid-1950s. Their politics were in flux at the time, and Kennedy being a New Englander probably helped him in New Englander-colonized Hawaii while Nixon's fifty-state strategy may have made a difference in Alaska. Once it was clear that Alaska wouldn't become a welfare state out of an inability raise enough taxes due to its small population, and Democrats staked a claim on civil rights to the benefit of majority-minority Hawaii, the two settled into their current state and neither party has really bothered to try flipping them for so few electoral votes.
Hawaii's stronger Democratic leanings has a lot to do with the Hawaiian Democratic Revolution of 1954 (
https://en.wikipedia.org/wiki/Hawaii_Democratic_Revolution_of_1954) which broke the control of the Hawaiian Republicans that was controlled by New England descended white landowning families. I doubt Kennedy being a New Englander had much of an impact here considering he was an Irish Catholic as opposed to the Yankee Protestants that traditionally ruled Hawaii.