What causes this condition called “nearsighted” vision?

Nearsightedness=shortsightedness=myopia.

These terms refer to a "refractive error" or focusing problem, where you can see up close without glasses to help, but not far away.

It is typically caused by an eyeball growing to a bigger diameter than normal. The front focusing parts of the eye don't "know" about the longer distance to the back of the eye, so they focus the image of a distant object short of where the retina actually is. This means the nearsighted eye's "default focal distance" is much nearer than normal, but at the expense of distance vision.

There is no doubt much more myopia nowadays than used to be the case even 100 years ago. While there is probably at least some genetic aspect to myopia, most research is pointing to what was once considered an "old wives' tale," that "needing glasses" comes from prolonged near work as a growing child along with less time spent outdoors in natural light.

J. Trevor Woodhams, Chief of Surgery - Woodhams Eye Clinic