Like others have mentioned, there are various options (donations/sponsorships/grants) that larger projects will generally have some of, but for smaller projects (99% of what’s out there, by project count if not usage), the answer is simply “it isn’t.” It’s done as a hobby, as a resume booster, or with the hope of eventually becoming big enough to hit one of those revenue streams.