One important element is the setting. A spooky place like an old, creaky house or a dark forest can immediately create a sense of unease. For example, in the story of the little girl and the glowing eyes at her window, the fact that her house was on the edge of a dark forest added to the scariness. Another element is the unknown. When the reader or listener doesn't know exactly what the threat is, it's much scarier. In the story of the traveler and the shadowy figure in the inn, we don't really know what the figure is or what it wants, which makes it more frightening.
The element of the unexpected is crucial. If a story follows a predictable pattern, it won't be as scary. But if something suddenly jumps out or changes in an unexpected way, it'll startle the listener. For instance, in the story of the traveler, the sudden appearance of the shadowy figure from the wall was unexpected. Also, a sense of mystery. Not fully explaining every detail, leaving some things to the imagination of the listener, can make a short scary bedtime story really effective.