These are really ancient plants, probably existing for at least 500 million years. They have simple leaves just one cell thick. They branch out of a stem that is so primitive it does not have proper roots, just anchoring threads, and so mosses can't carry water and nutrients from roots in the same way that most plants can.
But they compensate for this. Do you know how? By soaking up water equal to 20 times their weight. In this water are the dissolved nutrients these small plants need to grow. Like other plants they also take in carbon dioxide from the air and use sunlight as a source of energy. But because they cannot quickly replace any water lost if they were to be in direct hot sunlight, they can only grow in the shade of trees, or directly in standing water such as riversides and peat bogs in mountains.
Biologists call plants that live on trees without harming them, epiphytes. Moss species growing on or under trees are often very choosy about the species of trees they grow on.
If a drought does occur, they dry out completely and look a shrivelled and lifeless brown, but they remarkably return to life within a few hours of it raining again. And this is why you find them on which ever side of a tree trunk or branch is dampest, perhaps the top, perhaps one side, and not always the shadiest side - just the wettest side.
There are many mosses - including star moss and sphagnum.
Oh, and be kind to mosses. It takes them a long time to grow.