They are actually called light guns. When you shoot, the TV screen refreshes, and there is a line drawn across the screen when the refresh happens. Remember this is at 60hz (depending on where you live) so its not easy to see. Anyway, you're pointing your gun at the screen, and the gun is essentially a light sensor. When the part of the screen which the gun is pointing at gets drawn over with white, the sensor in the gun detects it and then tells the game "I can see white now, I'm pointing at the part of the screen you've just drawn". At this point the game can work out how far down the screen it has drawn, and how far along the current line, which gives a pretty accurate position of where the gun is pointing. At this point it no longer needs to flood the screen in white and can carry on drawing the game scene for the rest of the frame.
The game then draws a "splat" mark or whatever on the screen where the gun is pointed and kills off any baddie or whatever at that position on the screen. You think you've shot them, when it's actually the screen firing at you.
Edited with better info and to make sense.