Let's consider a light ray falling on a cuboid made of glass at the angle $\alpha$. Then there will be a reflected ray $A$. The ray will also refract. Let the refracted ray be $B$. Ray $B$ will be partially reflected at the other end of the cuboid. Let this reflection be $C$
By the reflection of the ray $A$ the phase will be changed. On the other hand, by the reflection of the ray $C$ - it will not.
Why does the phase change occur only when reflecting from a more dense substance (ray $A$)? The cuboid is located in vacuum.