Ok, you have a problem with your configuration, but one which is easy so solve.
When you HOME a machine, you are providing a REFERENCE for each of the axis.
The number behind the reference is not important, but the reference is repeatable...... so every time I home my machine, I know that the co-ordinates X0 (left to right), Y0 (toward and away from me) and Z0 (vertically up and down) will ALWAYS be the same position.
because you are sharing you home and limit switches, what you have done is setup your homed position as "0" for all axis {I presume}.
So, when you tell the machine to move G52 Z0.... it trips the limit switch.
The fix is easy.... provide a negative offset for your homing position... and then provide the similar number as your "Homing Backoff Units".
So..... go you your Settings >> Axis Setup >> and Choose the X axis.... on that page, set "Write Offset on Homing" of 0 (i.e. zero)
Whilst you are on that settings page, set "Homing Back Off" to 5 (i.e. 5mm)
Go to your Y and do the same.
For the X axis, set the Homing Backoff as "-5" (i.e. minus 5).... because the machine should move down after homing toward the table "+" (plus) is up and "-" (minus) is down for the Z axis.
if your machine is jogging in the wrong direction you must correct it:
Z + (plus) is uptwards the roof.
Z - (minus) is down towards the floor
X + (plus) is Right
X - (minus) is Left
Y + (plus) is away from you
Y - (minus) is towards you
you can setup something different .... but it can be confusing as those are the standard (common) directions.