This sensor is essentially a reed switch, encased in an ABS plastic shell. Normally the reed is 'open' (no connection between the two wires). The other half is a magnet. They're often used to detect when a door or drawer is open, which is why they have mounting tabs and screws.
This AT1315 door switch sensor is often used to detect when a door or drawer is open, it have mounting tabs and holes to screws onto door wall. Both working model NO and NC options available .