When switch S is open, the corresponding equivalent circuit diagram is as shown in the figure.
The equivalent resistance between A and B is Req=12+612×6+6+126×12=4+4=8Ω
When switch S is closed, the corresponding equivalent circuit diagram is as shown in the figure below
The equivalent resistance between A and B is Req′=8+88×8=4Ω