This is called an endoptic phenomenon. The eye has amongst the highest metabolic rate for any tissue in the body, higher even than most brain tissue. That's because the retina is incredibly energy hungry, when light shines into the eye, it actually switches retinal activity off, so in the dark your eye is even more active than it is in the light!

When you, for example, stand up from a hot bath, the momentary dip in blood pressure causes you to see funny lights because the blood supplying the retina temporarily drops in flow and reduces the oxygen and sugar available to the retina.

The eye is full of fluid and jelly called aqueous humour, so when you press on it the pressure gets transferred straight to the back of the eye, squashes the blood vessels a bit and changes the pressure. This reduces profusion, it stops blood going in so easily.

Secondly, the physical distortion of the retina itself can cause some photoreceptors to change shape and become less active, firing off impulses when they shouldn't be. This causes internally generated endoptic phenomena.