Seedlings stretch due to the influence various factors. In other words the way the genotype is expressed is determined by the biotic and abiotic factors affecting its growth. The site where the plants are grown may be conducive to stretching due to a nutrient deficiency or other factors like temperature or day length.
The source of the seed is also important. If the environment that the plants were from originally was consistant from year to year (for instance, indoors) and/or encouraged stretchy plants (crowding), natural selection may have passed on the trait for stretchy plants. If the seeds were from hybrid plants that were crossed "Willy-nilly" the variation of the offspring will blur the distiction of phenotypes.
When plants stretch due to competition for light, this is known as the "shade avoidance response phenotype" (SARP). The light reflected off of other plants has less red in it because the leaves of the other plants absorbed it already. This is how the plant knows how close it is to its neighbors. When there is less red, the plant stretches so it can compete better for the light. HPS lights are high in red spectrum, so plants grown under them stretch less.
Plants match their phenotype with the environment, but this can depend on other factors. Temperature and photoperiod can affect the response to red light by limiting which phenotypes are expressed. Higher temperatures, shorter photoperiods and dense planting make the plant more sensitive in its response to the amount of red.
The SARP is really an interaction between abiotic factors and the quality of light. The size of a plant that has stretched may be larger than a plant grown under a full spectrum, but overall yield will be less. A plant grown under a short photoperiod is more sensitive to red, but a plant with a long photoperiod period will stretch regardless of the spectrum because it has time to make a longer stem. In fact under longer photoperiods, the plants become less sensitive to red because seedling elongation affects the health of the adult plant.
The seedling is aware of it surroundings. The SARP isn't affected by photoperiod in a seedling because the seedling has to be aware of the density of the population, but if the day-length is short enough to induce flowering, then they will stretch. An elongated plant costs more to grow because your growing more stem and less bud. So under conditions of dense planting the temp and the photoperiod determne how close to plant to minimize stretching.