New Hampshire receives a steady flow of inward movement from Massachusetts Republicans who want to be within commuting distance in Boston but live somewhere with a more favorable political culture. There's a reason why a lot of the most Republican communities in the state are within a stone's toss from the MA border. As cringenat pointed out, about a quarter of NH residents were born in MA. If only native-born Granite Staters voted, NH would be about as Democratic as Maine is. Meanwhile, Vermont was colonized by hippies from Northeastern urban areas in the late 60s and 70s, which meant that in the aftermath of the religious right realignment and passing away of the old Yankee Republicans, Vermont became solidly Democratic.
Not to go off-topic, but this type of thing is discussed depressingly little here for this allegedly being a site devoted to more in-depth political analysis. Generational displacement is one of the hardest political trends to quantify or spin a narrative about with Tweets, but it is easily one of the most fascinating. I remember Adam Griffin showing one time that primary voters in Georgia who are over the age of 90 still pulled a majority of Democratic ballots, and I have found a few cool articles about older Southerners in the 1990s talking about how the younger generation is a lot more open to Republicans than they ever would be. A similar thing happened in Vermont, and while this obviously was only one factor, it is not often discussed. A flooding in of new residents or a strong generational shift in political attitudes/loyalties can have a massive effect on a state.