AT89S52 switched mode IO Pin 2 not setting to ground
You need to change your circuit and possibly your software.

The I/O pins are the so-named quasi-bidirectional standard for the MCS-51. These have internal pull-ups and open-drain transistors to drive them low. The pin input level can be read directly and there is no distinct 'input mode' or 'output mode'.

Remove R3 and R1. Connect each of your switches across an I/O pin and GND. Now, when a switch is closed, the I/O pin's internal pull-up is shorted to GND and the I/O pin reads logic '0'. When a switch is open, the internal pull-up pulls the pin high and it reads logic '1'.

In your software, write each port's SFR with 0FFh to drive out logic high. Then you can read each port's SFR to get the switch states.