There are a few options available. Like sourcehut and forgejo. Both self hosted capable.
But it's up to the projects to choose such a path. Many like the visibility and convenience github provides. Instead of focusing on self sovereignty for their code.