The pupil is a hole located in the center of the iris of the eye that allows light to enter the retina. It shrinks when light is shone on it because iris is constituted by smooth muscles. Around the pupil are circular muscles called the pupillae sphincter, which is under the control of the parasympathetic nerve fiber of the oculomotor nerve. When light shines on the retina, the impulse passes on to the pretectal neuron of the mesencephalon through the optic nerve, and then reaches the miosis nucleus of the oculomotor nerve, and outflows through the parasympathetic nerve fiber to make the pupillae sphincter shrink and the pupil shrink as well.
Well, it seems that you are quite a curious guy. So, it is true that our pupils could be changed if there are some external incentives on them and as you can see, when light is shone on it, the diameter of our pupils was shortened temporarily, that is called Pupillary reflex, which is one of the most common phenomenon. Just take it easy and it could just last a few moments.