As many plants do, many of vegetable do photosynthesis. For photosynthesis, chlorophylls, which are green, and carotenes, which are yellow to red, play important roles. When chlorophylls get less, you might see yellow to red color due to carotene. When chlorophylls are degraded, they get light brown. In some vegitable, such as tomatoes, lycopene, which is an intermediate of carotene synthesis, is accumulated.
https://en.wikipedia.org/wiki/Lycopene
Another popular pigment is anthocyanin, the color of which is red to purple. Various functions of anthocyanin are suggested from sun-shade, to an antioxidant, to attracting birds in fruits.
https://en.wikipedia.org/wiki/Anthocyanin