Sadly, float switches are notoriously unreliable. Since the switch portion of the assembly is internal, repair is not easy, and replacement is the usual fix. However, they more commonly fail in the "off" mode, so it may be that there is a short circuit in the wiring
that is activating the pump. The test is to isolate the switch by disconnecting both sides of the wiring
and using an ohm meter or continuity tester to see if the switch is functional.
Good luck, and welcome to the realities of boat