The effect that makes this possible is occlusion.

In mixed reality, occlusion means that objects closer to the viewer can block (hide or partially cover) objects that are farther away, whether they are real or virtual. By detecting the room’s spatial layout, the system can decide when a virtual object should be visible or hidden behind real-world surfaces like walls, tables, or furniture, creating a more realistic and convincing experience.

TL;DR: The mixed reality application uses the occlusion effect so virtual objects can be overlapped or hidden based on their position in the image.