The "gun" not so much shoots anything as looks at the tiny portion of screen at which you point it. It then detects when the phosphor dots get illuminated by the very fast flying electron beam making the picture on the tv or monitor. It can compatre the timing of the light to the timebase of the monitor and determine where in the picture the thing is pointing.
The screen picture is scanned from left to right to make horizontal lines and stacks these lines from top to bottom. A clever trick called interlacing means that first odd numbered lines are projected with gaps in between then the even numbered lines are filled in, so the vertical scan is done twice per frame. This reduces the visible flicker.
The neat software in the games console can sort out all of this within microseconds. Each line (on british tv system) takes 50 microseconds to scan and each frame is complete in 250 milliseconds. There are 625 lines in total, but for technical reasons you don't see all of them.