Composting helps in fertilizing trees by enriching the soil with essential nutrients, improving moisture retention, and fostering a habitat for beneficial microorganisms, all of which contribute to better tree growth and resilience.