What you are describing is a flashback. Flashbacks can be very scary and you have to learn that when you experience them that they pass and you can't stop them from happening. Once they finish talk to yourself and say "yes that happened but it's not now, I am safe now". That helps to reduce the strength of the flashback.
When we experience a trauma all we focus on is surviving so the trauma doesn't get processed. It's more a question our brain is asking and it will take time for the brain to finally accept that we are ok. It's a delayed reaction due to our just trying to survive something.