Myopia occurs when the eyeball is too long, or the cornea is too curved, causing light to focus in front of the retina rather than directly on it.