These are created using a laser diode (a mechanism by which laser beams are produced) reflected against a light sensor. These are hooked up to a circuit board of some kind, which then talks to a computer that has been coded to do an action (whether that is to sound a buzzer, to call the police, to lock the doors, or all three). When the beam of the laser is broken, a switch will flip on the circuit board, which will then trigger the computerized response, notifying you of any intruders in the area.