The short answer is because they contain the pigments β-carotene and lycopene which strongly absorb visible light in the blue-green part of the electromagnetic spectrum, around 400-600nm.

Both molecules contain an extended conjugated system of alternating single C-C and double C=C bonds. The ∏ electrons in the double bonds are delocalised over the entire conjugated system as a result of the overlapping of p-orbitals on adjacent carbon atoms, just as we have seen in alkenes and in benzene.

Conjugated systems can also incorporate the ∏ electrons of N=N and C=O bonds, as well as lone pairs of electrons from nitrogen and oxygen atoms (if they are in a p-orbital that is aligned). They also include aromatic rings, as seen below in the red azo dye Sudan I.

The visible light-absorbing part of a molecule which causes it to be coloured is called a chromophore.
When these pigments absorb visible light, electrons are promoted from a lower energy molecular orbital (ground state) to a higher energy molecular orbital (excited state). The difference in energy between these orbitals is given by

The greater the extent of the conjugation, the more stable the molecule and smaller the gap between the ground state and the excited state. This means a lower frequency of visible light is absorbed which is equivalent to a longer wavelength because

Buta-1,3,diene and benzene are colourless molecules despite containing a number of alternating C-C and C=C bonds. The general rule is that ΔE corresponds to the wavelength and frequency of visible light in delocalised systems of electrons with 5 or more ∏ bonds in the conjugated system.

ΔE is larger in buta-1,3-diene and benzene. When these molecules absorb ultra violet light (higher frequency) they promote electrons from the ground to the an excited state but since our eyes cannot detect changes in uv light, they appear colourless.
Phenolphthalein is an acid-base indicator which is colourless in acidic conditions and magenta (bright pink) in an alkaline solution.
How is this colour change related to the change in the structure of the molecule as the pH varies?

Both forms absorb ultra-violet light but the one on the right also absorbs visible light in the green part of the spectrum, transmitting complementary wavelengths. In alkaline conditions the conjugated system extends over the entire structure, stabilising the molecule and leading to a smaller ΔE between the ground and excited state.
Practice question
Cyanidin is a naturally occurring purple pigment found in flowers. Explain in terms of energy levels why this molecule is coloured whereas benzene is colourless.

Answer
When molecules absorb energy an electron is excited from the ground state to higher energy level. The frequency of the light absorbed is governed by the difference between these energy levels, ΔE = h𝛎.
ΔE in benzene is large and corresponds to the absorption of ultraviolet light, hence it is colourless.
ΔE in cyanidin is smaller and corresponds to the absorption of visible light. The complementary frequencies of light are reflected or transmitted, hence it is coloured.
Cyanidin has an extended system of delocalised electrons (more so than benzene) which stabilises the molecule and reduces ΔE (the energy levels are closer together).