this belief is likely derived from the experience of: dreams, hallucinations, fainting
At that time, people still do not understand any scientific theory that would explain why things such as dreams, hallucinations, or fainting happen. Because of this, they made up some explanation that couldn't be proven such as the existence of soul.