Here's what happens. When playing Duck Hunt you pull the trigger to shoot a duck out of the air. When that trigger is pulled, the TV screen goes entirely black for one frame. The light sensor uses that black screen as a reference point, which helps it account for the wide variety of lighting situations in the rooms where the game is being played.
In the next frame, the area the duck occupied turns white while the rest of the screen remains black. If the light sensor detects light in that second frame, your gun is on target. If the light sensor does not, the dog is going to laugh at you.