The little metal levers on the endstops are only held in by tiny metal prongs. If the latch comes off you can simply reinsert it by sliding in one side of the “fork” then the other side.
You may have to bend back the metal slightly in order for it to stay in.