White light from the sun contains all the wavelengths, but when it impacts on an object some of its wavelenghts are absorbed and some reflected. An object is coloured because of the light that it reflects. For example red objects reflect 'red' light, which is light with a long wavelength. Many vegetables and fruits are strongly coloured because they contain an especial kind of chemical compounds named carotenoids. These compounds have an area called choromophore, which absorbs and gives off particular wavelengths of light, generating the colour that we then perceive.
The chromophore is formed by a sequence of linear carbon-carbon double bonds (represented as C=C), much stronger than simple bonds (represented as C-C), so the atoms remain closer to each other. In general, it's necessary at least seven linear conjugated double bonds for a carotenoid to produce a colour. Besides, the bigger the number of bonds conjugated, the bigger the wavelength of the light absorbed and also the more red the vegetable, as you can see in this picture of the light spectrum:
The tomato is red because of the carotenoid lycopene, which contains 11 conjugated carbon-carbon double bonds. You can count these bonds in the picture below, they are selected in red (the atom carbons are omitted, only the bonds are shown). This compound is generated by the plant to protect itself from the air oxidation. So it's a good antioxidant useful for us too, protecting our cells against the action of free radicals (potent oxidants), which are one of the main responsibles of cardiovascular diseases, cancer and aging.