This is a great question, and a complicated one.
Trees reduce carbon in the atmosphere by building plant tissue out of it and locking the carbon away. Unfortunately this is only temporary, when the tree dies and is burned or rots, the carbon is released back into the atmosphere. Solar panels reduce carbon in the atmosphere permanently by generating power that would have been generated by fossil fuels.
Let’s put it into perspective. An average tree in the Canadian climate will temporarily reduce carbon in the atmosphere at the rate of about 20kgs of carbon per year. An average 10Kw solar array will permanently reduce the amount of carbon in the atmosphere by about 15,000kgs per year. We like trees too but when it comes to carbon there is no contest.