How to install another module when a module is being installed I have created a module (travel_list) that uses the Field Group module. I want the Field group module to be automatically downloaded and installed whenever the travel_list module is installed.

How can I achieve this?
If a module depends on another module, you have to declare it as a dependency. The way Drupal handles this, is through the *.info.yml files, which define the basic module attributes.

In 'travel_list.info.yml' add this key:

dependencies:
  - field_group:field_group


Doing that, whenever you install the module 'travel_list' it will enforce you to install 'field_group'; this means that if you try to install 'travel_list' module and 'field_group' is not installed, the installation will abort reporting that 'field_group' module is needed.

Developing an script that downloads and triggers the module installation is far away from good practices and can lead to a number of unpredicted situations, starting by the fact that the required modules of your Drupal are defined in the composer.json.