I concur with Robert, sounds like the internal pullup resistor is either not enabled, or has failed.
There should be a section in your configuration.h that looks like this:
// Enable pullup for all endstops to prevent a floating state
// Disable ENDSTOPPULLUPS to set pullups individually
And it should look like that.
If the #define ENDSTOPPULLUPS is commented out, then they won’t be enabled.
If it is defined, Marlin should still not leave those pins floating, the next section should define pullDOWN resistors instead to prevent that.
I’ve had the pullup resistor on one board fail. They’re really low power devices, so it can happen.
The actual value of the pullup resistor is noncritical. I used some 4.7k resistors from a junk box.
Change your endstop plug to a 3 wire type, and plug in a resistor from the (+) pin to the (S) pin. The (S) pin and the (-) pin go to the endstop as usual. There. You have just inserted your own pullup resistor. If the pullup resistor IS working, but it’s just noise… No problem. Worst case is that you have 2 4.7l resistors in parallel, so it’s effectively a 2.35k. The board will EASILY tolerate 470 ohms, (I used one of those on a RAMPS board by accident, misread the colour code. It worked for years before I retired the RAMPS board – which is now in my ZenXY table.)
Anyway, adding in your own pullup resistor is a simple matter, so long as you have something in a suitable range.I suggest between 4.7k and 10k.