In nature, most aquatic plants are marginal/marsh plants. Gaseous exchange underwater is 10000 times slower than in air - it's much easier for these marginal plants to grow when they have the aerial advantage as this gives them free access to CO2/O2 in air.
How does the plant detect whether it's underwater or not?
When it's access to CO2/O2 is cut off sharply by submergence. This leads to rapid accumulation of the hormone ethylene in the plant meristem, which induces rapid stem elongation in an attempt to break back up the water surface to access air. When CO2/O2 levels are poor, plants will put all energy available into stem elongation, even sacrificing the maintenance of older leaves, in order to access surface air to survive. This is why bare lower portions on stem plants is quite commonly seen in setups with no CO2 injection. To prevent overly long internodes, ensure good O2 and CO2 levels in your tank, which alleviates ethylene accumulation.
The higher the PAR levels in the tank, the shorter the internodes. Some stem plants will start growing sideways or creeping on the substrate in higher light levels. Plants positioned in open spaces in the tank receive significantly more light than areas beside hardscape or tall plants which can partially shade the surrounding area.
To what extent can we extrapolate what we know of terrestrial plants to our freshwater aquatic plants?
In terrestrial plants, blue light suppresses the hormones auxin, leading to shorter stem inter-nodal distance between leaf nodes. This is exemplified by experiments such as the one below:
However, most aquatic plants do not respond as directly to blue light as stem elongation is more affected by the flooding response mentioned in the first section 'Access to CO2/O2'. Depending on species, this can have a marginal effect on compactness of growth. The other factors such as overall PAR values and growth speeds have more impact on internodal distance.
One of the main factors in determining internodal distance is actually growth speed. Plants in faster growth mode tend to have longer internodes than plants in slower growth mode. Temperature is one significant factor that determines the rate of plant metabolism - cooler tanks with lower temperatures lower plant metabolism and give rise to more compact plants.
Slower growth parameters / slower growth rates (including lower CO2 and nutrient levels) give rise to more compact stem plants. Ironically, CO2 deprivation can cause stem plants to elongate to try to breach the water surface, however, high CO2 levels often accelerate growth speeds significantly as well, and this also gives rise to less compact plants.
The combination of high light, lower temperatures, lower nutrient levels and availability of some CO2 (say 10ppm) but not high levels will generally give the most compact plants.