Green leaves get their colour from the photosynthetic pigment chlorophyll. When deciduous leaves are preparing to separate from the tree in autumn, that green pigment begins to break down. This can then reveal other leaf pigments that were masked by the green, such as yellow and orange carotenoids. In other leaves, the breakdown of chlorophyll is accompanied by an accumulation of pigments known as anthocyanins, which can impart red or purple colours to the fated leaves. Some extraordinary leaves have both carotenoids and anthocyanins in their final weeks, which allows them to go through a showy progression of colours before they fall.
A version of this answer was originally published on Britannica’s Beyond.