Like I mentioned before, the way that things become youkai, or get spirited away, or have gods form etc; is really quite meta. Most people would like to think of these events as something internally-motivated, as if the setting of Gensokyo and its character interactions are what causes these events to happen, but it all really comes down to a matter of "if people believe it, it becomes true in Gensokyo". While a bit trivialized, this is how a major part of Gensokyo seems to run and it's a fantastically simple literary device. My usual simple example would be the creation of youkai and gods: all it takes is the fear of something in order for people to propagate fables and curses and hauntings and the like. The "people" as a group "create" a youkai by believing it exists. Then, as people discover scientific explanations to natural phenomena and fashion logic more and more, those fantastical explanations die off. This is how they end up in Gensokyo. ZUN keeps the details behind spiriting away and the like hidden and ambiguous on purpose in order to show that the move to Gensokyo is not a physical or volitional move at all, it just happens. Gods work the exact same way, except they are worshiped instead of revered. Sanae being worshiped as a god by performing miracles is why she would be considered a living god. Likewise, Marisa delving into so much magical experimentation and fighting other people are likely the reason why she might one day just exist as a youkai. The thing is that with Gensokyo, these fantasies run wild with no physical explanation, so in large it's self-sustaining. Ghosts occur because people may die and have unfinished business, but ghosts only actually exist because the concept of a ghost is totally valid and thought of as the norm in Gensokyo. It's all wonderfully meta.