Before Massachusetts was a state or a province it was a colony, the Massachusetts Bay Colony, to be precise, in the 17th century. This included the Eastern part of Massachusetts as it exists now, Plymouth Colony and Nantucket, parts of Maine, sometimes New Hampshire, as well as claims on territory in what is now Western New York state, Vermont, and elsewhere. This government went through some rough patches during the Glorious revolution in the late 1680s as it became part of the Province of New England then reverted back to more localized rule after several insurrections and then came out the other side in the 1690s as the Province of Massachusetts Bay, which included Eastern Massachusetts, Maine, New Brunswick, and Nova Scotia, plus various territorial claims. Notably this does not include the Province of New Hampshire (which had been grouped under the same rule as Massachusetts Bay during the mid 1600s and during the Province of New England period, but became its own English Crown Colony in 1691, though until the mid 1700s the governor of New Hampshire was the same person as the governor of the Province of Massachusetts Bay).
In 1697 Acadia (including Nova Scotia and New Brunswick) was returned to France, though part of it was reconquered by Britain in 1710, though kept as a separate province from Massachusetts (forming Nova Scotia). Later during the Seven Years War (also called the French and Indian Wars) the British fought to consolidate their hold on all of Acadia, expelling many Acadians in the process (many of whom would migrate to French Louisiana, becoming "Cajuns"), and expanded "Nova Scotia" into all of what had been Acadia (including modern day New Brunswick).
The area of Vermont, meanwhile, had been part of some territorial claims by Massachusetts bay during the 1600s but when the boundary with New Hampshire was fixed in 1741 these dropped away, though the territory of Vermont would go on to be contested by New Hampshire, New York, and Quebec up until it established itself as an independent Republic during the American Revolution. Meanwhile, the Province of Massachusetts Bay became the Commonwealth of Massachusetts during the Revolution, retaining its territory, which at this point included the current extent of Massachusetts plus Maine plus some territorial claims to the West (which were sorted out in the 1780s with the Treaty of Hartford). Finally, of course, Maine was carved out of what was then Massachusetts as a new state in 1820.
As you can see, the history of the territory is one of a large, mostly connected expanse (roughly "New England") being shuffled around and having pieces carved out of it here and there (Nova Scotia, New Hampshire), eventually resulting in two disconnected regions being part of one colony/province/commonwealth.