Areas where every level crossing is this good can be designated as quiet zones, but few municipalities want to spend the money on that. Train tracks are usually in industrial/commercial areas; homes near them are, shall we say, not centers of political power.
In Britain, within towns there's usually gates on either side of the road, so it's not necessary for the train to use its horn.
https://youtu.be/uaWG04vKYLg