It don't think it's quite open yet (should be sometime this month), but the new Ibis hotel at Cambridge station is right alongside the platforms at the north end of the station.
Across the Atlantic:
The
Station Inn at Cresson, PA is a decent, if slightly quirky, 'railfan' B&B alongside the triple-track NS mainline, with a porch out front you can sit and watch the trains all day and night if you want to.
The
Ramada Inn at Cumberland, MD is right alongside the CSX mainline in the centre of town (and the Western Maryland Scenic heritage line is on the other side of downtown) - you need a high up room to see over the trees between the hotel and the CSX railroad (they understand the problem at reception....)
The
Truckee Hotel, 5800 feet up in the Sierra Nevada mountains in California, had a basket full of earplugs on the reception counter when I stayed there last year - for use of those not wanting to be woken up by train horns through the night...(enthusiasts are made of sterner stuff, of course

)
View from the 2nd floor, train on the left, lovely scenery straight ahead