It's a short commute to Boston. By that, it's completely influenced by the Boston real estate market. Therefore, it's not an "average town".
In my SIL's town, which is still easily in the Boston commuter area, you can get more than 1000 ft for $400k. I looked.
Boston, NY, DC, Chicago, SF- all are areas that they dominate the real estate market within 100 miles. Not average.
Find "average" and you will find you can get a 2000 ft^2 home for $300k. Heck in Amherst, the median home price is $321k.
So your theory about every young person can't get a 1000 ft^2 home for $400k in all of Mass is wrong. Facts are facts.
It really isn't. From Woburn you're looking at an hour each way during rush hour on a normal day. Sure, you could commute 50 miles a day, but then you're talking three to four hours in the car each day. Most of the jobs in Mass are around Boston so that is where most people are going to live.