1 Answer
1

It is a phenomenon known as room amnesia, some research has shown that your brain may use physical barriers like the room and doorways as a way to compartmentalize thoughts.
One article summarizes it here:

The researchers say that when you pass through a doorway, your mind
compartmentalizes your actions into separate episodes. Having moved
into a new episode, the brain archives the previous one, making it
less available for access. It’s as if you slam a mental door between
what you knew and…what was I saying?