https://www.youtube.com/shorts/KVZxM7dpk70
It is hard to see, but he turns the second box 90 degrees before removing the lid. If the boxes are not perfect cubes, he might be able to fit the first box in the second box. I don't think the lid would close all the way, but it doesn't have to. It creates the illusion that the smaller box contains the larger one.