What many open source companies do is offer their software as a service. A good example of this is Bitwarden where you are free to take it and host it yourself. But if you don’t want to do that, then you also have the option to use the software hosted by the company on their own servers. On top of that you can also charge for support. A good example of that is what Nextcloud does.
Another thing I’ve seen is release the source code but charge for the binaries. In that case the user is paying for the convenience of not having to compile the software themselves each time there is a new version. Cryptomator for example has a mobile app which requires you to purchase a license in order to use. The app itself is open source so you could modify the source code to remove that requirement and compile it yourself. But doing this each time there is a new version is a massive pain and most people would just opt for the $15 one time fee.