Plants use hormones to coordinate growth. A hormone is a chemical messenger. Auxins are plant hormones made in the tips of shoots and roots. They diffuse back along the stem and, in a shoot, make cells elongate, so the shoot grows longer.
A growth response to a stimulus is called a tropism. In phototropism, shoots grow towards light. When light shines from one side, auxin moves to the shaded side of the shoot. The shaded side has more auxin, its cells elongate more, and the shoot bends towards the light. This is positive phototropism, and it gives the leaves more light for photosynthesis. The tip is what detects the light: if the tip is covered, the shoot does not bend.
In gravitropism, plants respond to gravity. Shoots grow away from the pull of gravity (negative gravitropism). In a shoot lying on its side, auxin collects on the lower side, those cells elongate more, and the shoot curves upwards.
Roots grow towards the pull of gravity (positive gravitropism). Auxin also collects on the lower side of a root, but in roots this extra auxin inhibits elongation. The upper side grows faster than the lower side, so the root bends downwards into the soil, where water and minerals are found.