The first step I would recommend is taking a good gun safety course, this will provide the training for safe handling of guns and how they operate. This will also make you much more comfortable around guns.
In order to purchase a handgun in MA, you must have a license to carry a firearm. You must be a US Citizen over 21 years of age in order to get the license, and must not have certain kinds of convictions on your record. This if very difficult to get in MA.
New Hampshire doesn’t require you to have a license or a permit to buy or own guns, with one exception: if you buy a handgun (not a rifle or shotgun) from a private party — as opposed to a licensed dealer — then by state law (RSA 159:10 and RSA 159:14) you must either have a License to Carry or be “personally known” to the seller.
I don't recommend purchasing a gun in NH and bringing into MA.
This is just a guide you should always check with your local law enforcement agency.
Good luck.
NRA Certified Instructor: Pistol,
Personal Protection In The Home
MA State Police Certified Instructor