Others have answered the crux of your questions, which is that it's basically donations... either from the admins by providing free access to their server, or by the community through Patreon or whatever.
But to put into context how much money we're talking about...
- A server to host 1k active users and 5k-10k registered users, you're talking about a 4cpu-8cpu box costing less than $20/mo. Plenty of nerds with decent jobs in wealthy countries are willing to write that off as a donation. This covers 99% of the <1k Lemmy servers in the world.
- The 10 biggest Lemmy servers still only have hosting costs of $50-$300/mo. That's not nothing, but there are probably 10 wealthy nerds in the world willing to write that much off each month. And those costs can be offset through community donations. These servers support 10k-40k registered users, it doesn't take a ton of donations to cover that modest expense serving that many people.
Now, if you count admin/mod time and expertise, of course... those costs would be huge. But those people either volunteer or get a bit of money from non-profits. But the hardware costs are modest.