I am going to make one more (last) shot at explaining this.
To start, we need to define a couple of things.
First, there are two sets of laws involved: federal law and state law. You need to meet the requirements (if any) of both.
Two, the words “resident” and “residence” are capable of two different meanings. One, which is “abode,” is any place you have the legal right of occupancy of and at which one can sleep. A person can have more than one simultaneous abode. The other, which is “domicile,” is the equivalent of citizenship, and you can only have one at any given time.
Everyone starts with a domicile by virtue of being born. One can change his domicile by (a) acquiring a different abode, (b) physically going there, and (c) going there with the present intention of remaining at that abode for the indefinite future.
An abode can be a house or condo that one owns (and hasn’t leased to someone else) or a house, condo or apartment that one leases for a term, but does not include a short-term hotel room or BnB.
Examples: You live in your only house in Massachusetts, have a Massachusetts driver’s license, and vote in Massachusetts. Massachusetts is your domicile. You then buy a summer house in New Hampshire, while retaining your ownership of the Massachusetts house. You spend each summer in New Hampshire but at all times you intend to go back to Massachusetts when the summer is over. You have a second abode in New Hampshire, but Massachusetts at all times remains your domicile.
Or you live in your only house (probably parents’ house) in Massachusetts, have a Massachusetts driver’s license and (if old enough) vote in Massachusetts. Massachusetts is your domicile. Then you enroll in college in Maine. Each fall you go up to Maine for school, living either in a college dorm or an off-campus apartment you rent. At all times you intend to go back to Massachusetts at the end of the school year, and after graduation. You have a Maine abode (at least during the school year), but Massachusetts remains at all times your domicile.
OK, now lets apply the foregoing.
Federal law requires that you may purchase a handgun from an 01 FFL only in your state of “residence.” Whatever Congress may have intended when it passed this law eons ago, the BATFE, which enforces it, has interpreted “residence” for federal Gun Control Act purposes, to mean “abode,” not “domicile.” So, in our two examples above, you may in compliance with federal law purchase a handgun from a NH 01FFL during the summer while you are at your summer residence (first example) or a Maine 01FFL during the school year while you are in your campus or off-campus abode.
Though as a practical matter, some 01FFLs don’t understand this, so you may have to convince them of the fact that “residence” for federal handgun purchase purposes means abode and not domicile. And, since you won’t have an abode-state driver’s license or voter registration, you have to have some other way of proving the non-domiciliary abode. Real estate tax bills and utility bills in your name with the abode address are commonly used. Whether the abode-state 01FFL will accept them is up to him.
As for state law, I am not aware of any limitation in Massachusetts, New Hampshire or Maine law that limits one to purchasing in those states only if you are a domiciliary thereof. (However, I am not licensed to practice in New Hampshire or Maine.) Massachusetts does limit you to purchasing a handgun in Massachusetts only either (a) from a firearms dealer who has a Massachusetts state-issued firearms dealer’s license or (b) from a non-dealer who is also a Massachusetts domiciliary.
Not covered by the foregoing is the question of “resident” versus “non-resident” licenses to carry. Some states require one to be a domiciliary in order to obtain a “resident” LTC or equivalent. Some do not. Some states don’t even distinguish between “resident” and “non-resident” LTCs or equivalent. I say again, that issue is not covered here.