It’s not about shade alone. A cliff or single tree provides shade, but a forest provides evaporative cooling during the heat across a huge area alongside shade, it ends up a noticeably different climate.
There’s some other effects such as photosynthesis converting sunlight into chemical energy which in the short term is like reflecting that energy into the sky. At night plant metabolism warms the environment slightly and blocking the sky reduces radiative cooling to space, but that’s generally a good tradeoff for comfort.