Boston is definitely bigger for every other type of engineering though than NYC. Most non programming engineering jobs in NYC would either be for a niche startup or would have something to do with real estate.
The Boston tech scene and culture (outside of physically being on the MIT campus) is awful. TripAdvisor and Wayfair, your examples, are two companies I would aggressively advise any friends from even talking to. While all the major players are there now it took them a long time to get there. Comp in Boston still lags NY and SF considerably, and in general Boston has always had a resistance to anything "new", it's politically liberal but otherwise a very conservative city. The biotech companies there have always been way more heavy on the bio than the tech. I've worked for Boston area tech companies multiple times , before and after the tech boom, and would never work for a Boston area tech company again.
NYC is on a whole other level. Not only do you have all the major players with much larger campuses there are far more startups and early IPO companies. There is the also entire world of HFT companies (Boston's finance scene is largely very old school investment management companies) which alone would be worthy of making NYC a techhub. I also disagree with your claims about the concentrate of tech companies. Tech related meetups and events in NYC are much larger, more active and have more exciting participants than in the Boston area.
Simply being in the orbit of MIT can have that effect, along with everything else you listed.
The issue with NYC from a perception as a hub of any one thing is that it's just so big with so many different things going on that tech just seems like one of many things going on there simply because of all the people.
As you say, NYC (like Silicon Valley) has always been more concentrated in terms of technology focus.
Silicon Valley has a high degree of tech but also a fair bit of climate tech which shouldn't be discounted.
I think that there's a tendency on the part of a lot of people to view "tech" through the lens of web-related tech but obviously there's a lot more interesting/important work going on than just that--whether in the Boston area, Silicon Valley, or somewhere else.
Especially if you include Massachusetts as a whole it’s absurd:
MIT
Harvard
Tufts
Williams
Amherst
Brandeis
UMass Amherst
Boston University
Boston College
Northeastern
Wellesley
Olin
Babson
Smith
WPI
The valley has a vibe in that everyone you meet is involved in tech work in some way and will talk about it to you or in public. It doesn't feel that way here, or you have to be a part of certain circles maybe. There are some small biotech meetup groups, but maybe they all do communication at the universities?
Still true today: http://www.paulgraham.com/cities.html
I discount DC a little because a lot of that is government and defense related (not a bad thing, just not my cup of tea).
Boston has a lot of diversity in tech, lots of health/pharma like Moderna, web companies like TripAdvisor and Wayfair, robotics like Boston Dynamics, tons of startups doing ai/ml, and it seems like every big company has a substantial presence here (Google, Meta, Amazon, Microsoft, Salesforce…)