1. Make the best use of conditions in which they live. 2. Prevent or reduce animals damaging or eating them.3. Increase chances of survival amongst many different plants or species.4. See 1, 2 and 3.
Plants and animals adapt to there surrounding i.e. a cactus couldn't live in the arctic because it has adapted to living in deserts where its spines collect all its water, so it doesn't dry out. Same...
so easy by the sun the sun gives it energy to make it own food but not alone carbon dioxide is in it to you should already know that since you aksed this question