An out of body experience occurs when the mind is concentrated and the body goes to sleep. It's a skill that can be learned. It takes some people months of practice, while others do it on their first try.
It can be scary because we're essentially confronting the unknown, but concentration helps with that. Fear is a distraction that takes you away from a single pointed mind. When you recognize fear or worry popping up, you gently return to your object of concentration until it goes away.