Your spirit is an extension of your soul that exists between the soul and the physical body. If you have a soul, you have a spirit. It is your conscience that exists outside of your body.
For example, if you are sitting in your living room, your body and soul are in that living room with you. Your spirit, which is not contained, might be keeping an eye out on your kids and inform you via a feeling if something is wrong.
Your spirit is what gives your soul the energy of feeling. It relays information back and forth between your physical body and your soul. Your soul can be seen as an energy wave and your spirit can be seen as energy sparks.
In the case of ghosts, you are looking at someone’s spirit. It is a 2D version that can still have a presence or in some cases, a semi-solid appearance.
When you dream, your soul is still in your body or you would be dead. Your spirit leaves your body and travels. Ironically, while you dream, your spirit could be considered a ghost to someone else because they might only see your spirit. While you dream, your spirit could also be interacting with other spirits and it is common to hear someone say “I talked to my dead grandparent in my dream.”
If someone is in a coma, their soul is still in their body but they cannot talk or move. The reason is because their spirit has left their body and is wandering around. When they wake up, their spirit is back in them.
When you die, your soul leaves your body. Your spirit can sometimes linger because it is not sure where to go. In some cases, your spirit rejoins your soul in the spiritual right away. At other times, it tries to head towards the physical body. When it discovers that the physical body is gone, it returns to the spiritual to recombine with your soul. The spirit may take time in the physical to return but eventually it always returns to the soul. Once it recombines with the soul, you have the option to reincarnate again. This whole process happens instantaneously from the perspective of your soul because there is no time and space in the spiritual.