In my experience it's usually (but not always) one of two things.
The first is disappointingly mundane and obvious. The human brain operates by learning and identifying certain patterns, such as human figures and faces. This works well enough most of the time but it can be fooled into producing "false positives", especially when little detail is visible (such as low light, or objects in one's peripheral vision). Several "shadow person" experiences I've had ended with me discovering exactly what mundane clutter my brain was picking up on.
The other, somewhat more exciting cause of "shadow people" are low-level astral(?) beings that, like animals, mostly just want to eat. But what they eat is energy, and one of the easiest kinds of energy for them to get is human fear - that is, they get fed from scaring the bajeezus out of us. This class of entity is probably best known for its role as the "sleep paralysis demon" for the way it takes advantage of the hypnagogic state in which the paralyzed sleeper is trapped to freely extract fear from its captive audience. They are easily dispelled with very basic techniques, as they are in fact far weaker than humans. One need only reach out and "grab" them with one's energy/aura/whatever and they drop the illusions and panick like a stuck animal, and flee when released.
You might see shadow people for other reasons too but like unless you've really gone out of your way for it you likely don't have the attention of a malevolent entity, either you need to clean your room or clear the energetic "air" around you.