How we know
The 2011 paper by Radvansky, Krawietz, and Tamplin in the Quarterly Journal of Experimental Psychology ran three separate experiments. Participants carried objects through virtual rooms on a screen, through real rooms in a physical building, and back through doorways to the original room. In every condition, memory of the carried object dropped sharply right after crossing a threshold. Crossing the same physical distance without a doorway produced no such drop. Returning to the original room did not restore the lost memory, which rules out simple distance or distraction as the cause.
The mechanism is event segmentation. Your brain treats each room as a discrete event. The doorway is the boundary that closes the previous mental file and opens a new one. The previous file is still there, but it is no longer the one currently loaded.
What it means
You are not forgetful. Your brain is doing exactly what it evolved to do, which is split continuous experience into chapters so you can retrieve them later by location. The annoying side effect is that the chapter you just closed takes a beat to reopen. That beat is what you experience as "wait, why am I in the kitchen?"
Two practical implications. First, the standard advice to walk back to the original room works because it reloads the previous chapter. Second, if you are about to walk somewhere for a reason you need to remember, say the reason out loud before you cross the doorway. Saying it ties the memory to a verbal cue that survives the room transition.
The 2021 replication
A 2021 multimodal replication by McFadyen and colleagues found the effect was smaller than the original 2011 paper reported and depended heavily on cognitive load. The doorway effect is real but its strength is task-dependent. If you are deep in conversation while crossing thresholds, the effect is much stronger than if you are focused on the object you are carrying. The mechanism survives. The magnitude is task-dependent.