The provide section in your composer.json tells composer that your package provides all classes from all possible ext-mongodb packages (i.e. the MongoDB PHP extension). This means that even on systems where ext-mongodb isn’t installed, composer will simply assume that you’re providing the functionality yourself and will happily install everything, just for you to figure out that if the extension isn’t loaded in the first place, you still won’t be able to call things.
The correct option is to ensure that composer sees the extension as installed: if it doesn’t detect it as installed, any code executed in composers context (e.g. certain scripts that may already lode code) will fail to complete successfully.
To debug this, we can start by running composer diagnose. This will output information about your system, including the PHP binary path. You can then run this binary with the --ini option to see which ini files are loaded. Likewise, running the binary with the -m option shows which extensions are loaded and you can verify that the mongodb extension is loaded successfully.