This is a common problem. I think you'll find the answer somewhere if you search the forum for limit switch
As far as I can remember the command to display the limit switch values is M119
Move X Y and Z in their positive directions by 10mm, and then try M119 all three limits should not be activated
If they are activated, try holding the switches as if the carriage was pressing onto them, and issue M119 again.
If the state changes, for the switch you are holding, you may have wired the switch the wrong way around (I think this may also be configuratble in Marlin), but it may be easier to re-solder etc
If the value doesnt change, I suspect you've got a bad contact or its not plugged into the correct socket.