I found playing team sports competitively does more for me mentally than solo exercise. I realized this while in uni/college, playing intramural sports which were competitive but we weren't stupid competitive. I always felt great afterwards, even when we lost. I didn't get the same effect from jogging/lifting on my own.
Probably also thanks to the social interactions with your teammates. You socialise more, chat more, laugh more and all that makes our ape brain happier ig
I lived with half of my teammates at the time, so I don't think it's as simple as saying it's due to the social interaction. When it's competitive the entire focus is on winning. Sure you have some chuckles in the down time, but there's also plenty of irritation/frustration mixed in. We gave it our all and let each other know when we screwed up and our opinions on how we needed to fix it.