People buy houses next to airport runways; and then complain about the noise. So we find pilots now doing stunts that would make a fighter pilot proud, like throttling back their power seconds after leaving the runway and making sharp turns all to prevent someone from hearing too much noise. I don't recall if that's O'Hare or Midway in Chicago where they have to perform that nonsense, but regardless it's a dance that pilots should never have to do!
So I'm not at all surprised that people buying a house next to a train track never consider the noise associated with it.
The pilot pulling back the power and banking sharply just after takeoff is called a "Noise Abatement Procedure" and has been used for decades at many airports around the world. That and the issue of neighborhoods springing up around long established airports, then the residents complaining about noise were both mentioned in the 1968 novel
Airport by Arthur Hailey (Don't remember if these events made it into the movie)
As for railroads, I don't think I could handle living next to a grade crossing that trains blow for in the middle of the night. I've heard you can get used to it, and that people get used to living right next to and level with the elevated tracks in NYC or Chicago, but I don't think I ever could.
However, 2 of my favorite places I lived in the past were both near Amtrak routes:
The first was in a place on a hill that overlooked the 10 freeway East of downtown LA where the tracks run in the median...Many nights I would be out on the balcony with the freeway traffic a wash of white noise, knowing the scheduled departure time. A low throated rumble could be heard over this noise that got gradually louder until the rumble was revealed to be the sweet sound of a pair of GE P30CHs tugging the short string of Superliners that made up the Sunset Limited.
The Second was near the Eugene Yard where it has a slight bend in the middle. I had a clear view of the yard across a couple hundred yards of a large field and a road. The main is welded rail there, but there is one joint that was audible when trains rolled over it, must be for signal insulation between blocks. Both the twice a day Starlight and the 4x a day Cascades trains were very distinct in sound after the locomotive noise had faded and you could hear the car wheels rolling over the joint....clickity clack clickity clack for the Starlight and clack, clack, clack for the Talgos followed by the clickity clack of the NPCU if it was trailing. The passenger trains were noticeably lighter sounding than the run-through freights that passed. The Eugene Yard is lightly used by freights now, but occasionally there would be a freight that would start out from a dead stop in that part of the yard and it was music to the ears to hear that slack action going left to right or right to left across that field as the train got moving.
Thankfully neither of these places was near a grade crossing so I never heard train whistles except the occasional short toot-toot startup signal from a freight about to move.
The place I live now is at least a couple miles from the nearest tracks and grade crossing. Sometimes in the still of the wee hours of the night when the city is sleeping, I can clearly hear the faint roar of locomotives notched up and the whistle blowing for crossings even across that distance when I am indoors with the windows closed. When the city wakes up, I can't hear them at all even if I'm outside.
One thing I find interesting though. I've watched train vids from around the world and many other countries don't seem to use the train whistle at all for crossings, even where there is no crossing arms or gates. There seem to be few if any crossing accidents like we have here in the US, or perhaps we just don't hear about them.