Massachusetts' state legislature is heavily Democratic (they currently hold supermajorities in both chambers), and because of that voters are willing to elect liberal Republicans to put a check on them.
Exactly this. The State Party is still a Rockefeller one; it never got aboard the Religious Right train that derailed the GOP federally in New England by association; people around here still distinguish federal issues from state ones.
Also, back to OP, they DID vote for Reagan in 80 and 84 and elected Ed Brooke and Scott Brown to the Senate, all in many of our lifetimes, so it's inaccurate to say "never."
The MA GOP is becoming more Trumpian though. Hard to say if after Baker leaves, they'll elect another R governor for some time.
And if the GOP had somehow nominated George Pataki, they would have inched in his direction. The MAGOP is still part of the national GOP in a sense, and they have to conform SOMEWHAT. I think once there is another Democrat in the White House, the MAGOP will just do what's best for the MAGOP again.
It's not like the ALGOP would've behaved much differently under a President Pataki for what it's worth. States where parties focus less on national issues and more on local issues will always be less impacted by national trends.