Pupil dilation (mydriasis) is a natural process. The width of the pupil is controlled by sympathetic and parasympathetic nervous system that is independent on our will. Sympathetic system causes dilation and parasympathetic constriction. Under normal circumstances, the width of pupils varies according to changes of lighting level. For a better understanding of this text I suggest to also read an article dedicated to pupil constriction.
Lighting changes, stress factors, looking into distance
Mydriasis occurs in darkness. Light, on the contrary, causes pupil constriction. Similarly, certain pupil dilation occurs in stress situations and when looking at long distance.
Medication and drugs
A number of chemical substances cause pupil dilation. Quite specifically we use this effect in mydriatic drugs that are administered in form of eye droplets. Eye dilated by such medication is easily examinable by ophthalmologist. As a side effect pupil dilation occurs when abusing certain drugs (marijuana, LSD, magic mushrooms, cocaine, methamphetamine and amphetamines) and medication (many antidepressants).
Sudden onset of unilateral mydriasis following a head injury is typical for epidural hematoma. Epidural hematoma is caused by arterial bleeding to space above dura mater. Bleeding can sometimes oppress ocular nerve that leads parasympathetic innervation to the corresponding pupil. Disruption of parasympathetic innervation causes pupil dilation. This is a medical emergency that is fatal without proper treatment.
Stroke that affects parasympathetic system controlling pupil width can cause unilateral mydriasis.
Parasympathetic disruption followed by bilateral pupil dilation occurs in severe stages of intracranial pressure elevation. Mydriasis unresponsive to light exposure is in this case is associated with a very poor prognosis because it accompanies irreversible brain damage.
All cases of bilateral or unilateral pupil dilation with unclear cause should be followed by medical examination, ideally by an ophthalmologist and neurologist. If there is pupil dilation in one eye after a head injury, neurologic examination including brain computed tomography must be immediately executed to rule out or confirm epidural hematoma.