Minor refactor prepare_module
@lhoestq this is the PR that I mentioned to you, which can be considered as a first step in refactoring `prepare_module`. closing in favor of #2986 
Start to refactor `prepare_module` to try to decouple functionality.

This PR does:
- extract function `_initialize_dynamic_modules_namespace_package`
- extract function `_find_module_in_github_or_s3`
- some renaming of variables
- use of f-strings