@Ilsa Each instance (or server) is maintained by a person or a group that decided to start it. There are always some costs, and these are covered by these people, sometimes they might have a fund raiser, or sell some merchandise, things like that.
since the goal is to create a social environment and not making profits, people are usually not here to make cash, but to enjoy conversations with like minded people.
The Mastodon project itself, which is led by Eugen R., has a Patreon account that has received some generous support from a variety of people. That allows Eugen to work full time in this project, as well as paying the substantial costs of operating his own instance - mastodon.social, which is one of the largest Mastodon servers and must cost quite a bit monthly in hosting fees.