Well that is a good Question: Now the Block M is free to slide that means there is no constraint on it. So therefore the The block M slides With a downward acceleration of g. Now the syatem as a hole also moves with an acceleration g. Thereby each and every part of the syatem would experience this acceleration. Now lets us jump into the frame of reference inside the system NOw lets us write down the F_net = ma for the small block now since the block moves downward with an acceleration g a ffom the frame considered we have to apply a psedu force of magnitude ma exactly opp to the block acceleration then then the acceleration of the block is zero and thereby we make it an inertial frame of reference kx-mg =0 kx= mg
@Raman's answer I am not that sure whether the pulley would move inside