STEM is a vast neural network formed by linking together the brains of many people. Their conscious and subconscious mind; their perception; their memories; their emotions. Everything links together and creates what is functionally an alternate reality. Another world. And the way a certain organization is interested in it, it might actually be another dimension, but it's too early to say.
At any rate, there are still laws — an internal logic, created by everyone contributing — that governs the STEM world. Gravity still applies; time still passes. Locations like the city, village, etc, have a fixed geography. Destructible objects can still be destroyed. But the host of the world — Ruvik — is capable of imposing another layer of reality, the Horror Zone, drawn from his subconscious. And it appears that when he finds people, he can take them to other locations in STEM at will. But therein lies the rub: While he's the master of the world, Ruvik is not all-seeing or all-knowing. He still has to search for Seb, Leslie, etc., in order to deal with them.
That's where his pawns come into play. The Haunted are people, living (still jacked into STEM) or dead (killed while connected), whose minds (or echoes thereof) have been corrupted by Ruvik's madness. In Ch. 2, Seb comes across several people who are entranced by a lighthouse on the lake — a lighthouse that according to a note near the fire, they don't remember being there, yet every time its beacon passes over them, they feel like they lose their memories. The lighthouse sweeps the surroundings like a searchlight — it is a symbol for Ruvik's searching eye. According to the model viewer, the Haunted crave to have their memories back, which is why they feast on the brains of their victims, thinking they'll find their lost thoughts inside.
Other creatures are also the result of merging with Ruvik's madness. AlterEgo, with its two heads, is the result of Ruvik merging with the mind of someone with dissociative personality disorder. The Keeper is a man (with a backstory in the DLC, The Executioner) who merged with Ruvik's desire to keep his secrets safe. Laura Reborn is Ruvik's guilt over the death of his sister, and the fear she'll come back for revenge; her weakness to fire is likewise the result of his trauma over the incident at the barn. Quell is Ruvik's desire to stay hidden (fitting for a creature capable of optical camouflage). Amalgam Alpha and Amalgam, as their names suggest, are the combination of many minds with Ruvik's madness. Shade, in the Kidman DLC, is Ruvik's desire to find Leslie — hence the searchlight, another use of that symbol. And one of my favorites is Trauma, the creature with the broken crucifix on its back — Ruvik's concept of death and rebirth, and the rejection of the religion his father forced on him.
And yet other creatures come about in different ways. The giant spider, Heresy, is someone who rejected STEM and became a lost soul within it. Shigyo is the mind of a victim who perished while drowning; they were women self-conscious of their crooked smile, hence the braces. And sometimes the monsters are real-life creatures, remembered by someone connected to STEM. Therein lies some intriguing implications.
It's heavily suggested an Illuminati-like cult had been working on their own prototype of STEM for centuries, maybe millennia. We see their work in the lab under the churchyard cemetery at Cedar Hill. They also created monsters such as Sentinel and the Twins. Clearly, someone linked to STEM has vivid memories of these creations, the lab, and the rest of Cedar Hill, hence why that data was available in the STEM world.
In fact, the other locations have similar suggestions: The Village of Elk River appears because Ruvik abducted villagers from there for his experiments, blaming them for the death of his sister when they set fire to the barn to protest his family buying land. When those villagers were connected to STEM, they contributed their perception of the place, their memories and emotions. Same goes for residents of Krimson City who were abducted and connected to STEM, creating the city within the STEM world. And of course, Ruvik himself is the reason for the Victoriano estate being there. And with mental patients being the main source of material for STEM, it's no surprise that Beacon Mental Hospital is the nexus of this world.
A foreign organization instated Dr. Jimenez at the hospital. I can't recall whether he guided Ruvik in his research or if Ruvik found evidence of the cult's STEM and went about completing it in order to create a world where his sister could be restored. Either way, Ruvik killed his parents and agreed to continue donating to the hospital in exchange for mental patients to use in his experiments. And Dr. Jimenez was happy to oblige. When the work was done and STEM was complete, the organization turned on Ruvik and destroyed his body. Only his brain remained as a key component of STEM. But what they didn't anticipate is that his unstable mind would remain at work in the system, a malevolent force that they now needed to exorcise if they were to use that alternate reality for their own purposes. Perhaps this is why numerous policemen were jacked into STEM, in the hopes one would take Ruvik down.
Of course, Ruvik ends up escaping. He tracks down Leslie, the mental patient with an especially pliable mind who emulates the thoughts and behaviors of others. Ruvik supplants Leslie's personality and escapes into the real world. And this is where the ending becomes a bit interpretive: Seb's headache and Leslie glitching out once they're back in the real world. If I recall correctly, I see this as Leslie (now Ruvik) still able to exert influence over those who connected to STEM. What Ruvik will do next remains to be seen. Presumably he's out for revenge.