It's likely that your end stop wiring is picking up interference.

https://docs.duet3d.com/en/User_manual/Connecting_hardware/Sensors_endstops#interference