It is simply a switch which is activated by something "hitting" it. There are many different types of limit switches.
If you have a mechanism driven by a motor, it is very helpful to know when you have reached the end of your motion range. You can to this with a mechanical switch which is simply a micro switch with a arm attached. When your moving part compresses the arm the switch flips and turns off your motor (That is not the actual mechanism, but essentially what happens).
There are also optical limit switches, for these you attach a "flag" to your moving part, the flag (a tab of metal) passes through the optical switch it blocks passage of light (the source is a LED) and trips the switch.
Limit switches are on virtually all electro-mechanical mechanisms which involve movement of significantly massive parts. In modern equipment they are usually monitored by the software which is controlling the motion.