I think that one thing shared across everything fun is challenge. Not just a challenge, but one that is possible to make progress against. Participation in shared goals often plays a role, but without challenge, boredom reigns.
Nobody joins a recreational sports team to sit on the sidelines or to just wander around the field of play. They join to participate, to contribute, and to meet the challenge of making important contributions, which means gaining or refining skills.
The same could be said of joining a community band.
Why are video games so popular? If there was no difficulty getting through or it was impossible to get through, they would fall flat.
In any activity that I call fun, whether it's going for a row, building a boat, writing a new bit of software, or tackling calculus, there is always an element of challenge or opportunities for continuous improvement.