I think "D&D" generally is incorrect, but 5e is certainly correct (and in that manner, I agree with your post).
Generally, I've been able to run "horror scenarios" in D&D. There are two primary ways to do this:
1. Narration. Just like telling a good ghost story, the ability to narrate and place certain emphasis and pacing while describing things can heighten dread and tension. This can help you create that "horror" feeling you are looking for. But while the atmospherics can be wonderful, the issue that you run into is that mechanics don't support it. If everything is just a bag of hit point, then who cares how spoooooooky that bag of hit points might be? The divide between mechanics and atmosphere is difficult to overcome.
2. Mechanics. If you use older editions, there are mechanics (such as aging, level drain, insta-death, and so on) that are legitimately terrifying; these mechanics, or even the thread of these mechanics, can make the game much scarier.
In other words, I agree with you on modern D&D, but it is possible to have a spooky game with older editions if you're looking for it. Put another way, there's a difference between old-school undead and their neutered modern forms.