look at the end stops as well. make sure that the pull ups are enabled in firmware if using mechanical switches.
also make sure to use correct side of contact switch some setups are normall open, some are normally closed.
it would be easier to help troubleshoot if we know what printer model or variant you use as well.
read here on more info for mechanical switches, and for motor setup
[
reprap.org]