I have suffered from quite severe anxiety and stress since I was young, which has gotten worse as I have got older and has caused me a lot of problems and mild depression.
I don't know if this is related or it is the cause or what but I have also had this psychological problem where I feel detached from my surroundings, as if I am there but I don't seem to be aware of them. I often stare into space and this is the embarrassing part - people often see me doing this. They say I look like I am 'in my own world' or 'dazed'. I can stare at an object and still not focus on it or beware of it. It's like my mind and eyes are not in tune with each other. Sorry if this sounds weird but I don't know what to do. People keep noticing, especially when I am looking them in the eye and ask me what I am thinking and I find it really embarrassing and try to hide it but I don't know how?
I get that too, although it sounds like you get it more often than me. I've sometimes disappeared off into my own world to the extent that people have been calling my name for several minutes and I've simply not heard them.
Since it's bothering you I'd say it's worth mentioning to your doctor - they'll be in a better position to judge whether it's related to your anxiety and the like, and whether something should be done about it.
I do this when retrieving information I know I have seen/read passively.
E.g. someone asked me what the higgs boson was in school and I hadn't studied it but I remember something about it being on about it on the news, so I sat there for about 5 minutes in my own world and recalled the event then snapped out of it , gave a 10 minute answer - not knowing what 1/2 of it meant - and then people were like They think it's pretty cool, as do I... that I can store info passively and then retrieve it. I'm not sure if everyone can do it and I have no idea how I do it... or if it is a problem, though I have no intention on fixing it if so.
The only difference is I do it intentionally to completely focus and you don't, therefore I would perhaps consult a doctor if it's troubling you.
I do that quite a lot - I can be staring right at someone and not recognise them because my eyes aren't actually focussed on them. I've never talked to a doctor about it, although I am being treated for bipolar disorder.