Eh, I think staying in Brooklyn will be fine to visit the Manhattan sites as long as you're close to a subway stop. No need to pay midtown prices if you can find cheaper accommodations in the outer boroughs. I agree with other commentators who say to rent the car on the way out of NYC (Brooklyn might be a better bet for a non-airport car rental location) but I would add to drop off the car on your way into Boston unless you are 1000000% certain your accommodation offers parking. Believe it or not, it's easier to street park in NY. As a non-resident if you don't have off-street parking in Boston might as well use the tow lot as your parking spot lol.
I would highly recommend AMNH in NY for kids and adults alike though be aware it gets extremely busy. Under-the-radar museum picks in NY are the New-York Historical Society (right across from the Museum of Natural History, nice movie) and the Museum in the City of New York. The Frick recently reopened and I've heard great things. Also tbh I think the Brooklyn Botanic Gardens are better than the New York Botanic Gardens if you were planning on doing that although idk what the plant life is like in October. The tenement museum is fun. If the kids (or you) like trains the Transit museum is awesome, and all the kids in NY have shirts with the subway line of their first initial from the gift shop.
In Boston the Harvard Art Museums are free and very nice. Should be nice and quiet on a weekday. While you're in Harvard Square, there are also donut-focused walking tours that could be fun, but I've never personally taken one so I can't vouch. Boston doughnut culture is real. Museum of Fine Arts and Isabella Stewart Gardner are other nice art museums. If you like American history the JFK museum is nice and way bigger than I expected. Of course there's also the Freedom Trail and such. For about $17 a person you can get a guide dressed up olden timey to show you some of the best sites. Also, and this is out of the way, but if one of you is really into trains (and I mean really into trains, this is OUT OF THE WAY), a ride on the Mattapan Trolley is a nice chance to see a vintage trolley in real use.
There's plenty to do in both cities and I wouldn't limit yourselves to my suggestions but do what sounds interesting. Come back to the forum if you have questions about a particular attraction that gets recommended and I will give you the skinny (for example, lots of places will recommend the New England aquarium and though it is nice, it's not worth the admission fee if you are a tourist as chances are you have an equally nice aquarium in your home city).
NOW here's the thing. Salem? In October? I've done it and it is fun to walk around, see people dressed up, and visit the street vendors peddling spooky wares. But it will be CROWDED and you will have to wait on line just to get into some stores. Not to mention you'll really have to shell out for parking, and it might not even be close to the action. Salem is a really nice town and I'm not saying DON'T go to Salem - just be prepared and know what you're getting yourself into. If it doesn't sound like a good idea for your family but you want old buildings, cute shops, and ocean, Newburyport, Portsmouth, NH or Portland, Maine might be better options.
For food, Xi'an Famous Foods is a beloved NY chain. Also bagels of course - try a couple places and see which is your favorite. For a true NY experience, go out in the morning for half a dozen bagels, cream cheese and lox, and pick up tomato, red onion, and capers at a grocery store, pile it on high open-face style, and enjoy :)