### Summary

In the dependency resolution stage, ansible-galaxy appears to reference https://galaxy.ansible.com/api/v2/collections/xxx/yyy even though it successfully references a collection that exists in collections_paths. I have not tried with other modules, but I'm confident this pattern is consistent. 

I've verified it happens in recent versions as Ansible Core 2.12.4 or  2.12.0, but also in older versions as  Ansible 2.9.25.

Possible workarounds (for Ansible Core 2.12.x):

- Specify where the dependencies are locally
```yaml
[root@aap21 ~]# cat requirements.yaml 
collections:
  - source: amazon-aws-3.1.1.tar.gz
    type: file
  - source: community-aws-3.1.0.tar.gz
    type: file

[root@aap21 ~]# ansible-galaxy collection install -r requirements.yaml -vvvv 
ansible-galaxy [core 2.12.0]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-galaxy
  python version = 3.8.6 (default, Jan 22 2021, 11:41:28) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
  jinja version = 2.10.3
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
Reading requirement file at '/root/requirements.yaml'
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Installing 'amazon.aws:3.1.1' to '/root/.ansible/collections/ansible_collections/amazon/aws'
amazon.aws:3.1.1 was installed successfully
Installing 'community.aws:3.1.0' to '/root/.ansible/collections/ansible_collections/community/aws'
community.aws:3.1.0 was installed successfully <===
```

- Manually install the dependencies **beforehand**, and then use `--no-deps` to install the final package (for Ansible Core 2.12.x AND Ansible 2.9.25)
```yaml
[root@aap21 ~]# ansible-galaxy collection install amazon-aws-3.1.1.tar.gz 
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Installing 'amazon.aws:3.1.1' to '/root/.ansible/collections/ansible_collections/amazon/aws'
amazon.aws:3.1.1 was installed successfully <====

[root@aap21 ~]# ansible-galaxy collection install community-aws-3.1.0.tar.gz -vvvv --no-deps
ansible-galaxy [core 2.12.0]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-galaxy
  python version = 3.8.6 (default, Jan 22 2021, 11:41:28) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
  jinja version = 2.10.3
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
Starting galaxy collection install process
Found installed collection amazon.aws:3.1.1 at '/root/.ansible/collections/ansible_collections/amazon/aws' <==
Process install dependency map
Starting collection install process
Installing 'community.aws:3.1.0' to '/root/.ansible/collections/ansible_collections/community/aws'
community.aws:3.1.0 was installed successfully <===
```


### Issue Type

Bug Report

### Component Name

ansible-galaxy

### Ansible Version

```console
$ ansible --version
ansible [core 2.12.0]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.6 (default, Jan 22 2021, 11:41:28) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
  jinja version = 2.10.3
  libyaml = True
```


### Configuration

```console
$ ansible-config dump --only-changed
$
```


### OS / Environment

```console
 $ uname -a
Linux aap21 4.18.0-240.1.1.el8_3.x86_64 #1 SMP Fri Oct 16 13:36:46 EDT 2020 x86_64 x86_64 x86_64 GNU/Linux
 $ cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.3 (Ootpa)
```
### Steps to Reproduce

In an environment without internet access (or in an isolated environment), try to install a module that has dependencies already satisfied.

```yaml
[root@aap21 ~]# ansible-galaxy collection install amazon-aws-3.1.1.tar.gz 
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Installing 'amazon.aws:3.1.1' to '/root/.ansible/collections/ansible_collections/amazon/aws'
amazon.aws:3.1.1 was installed successfully <====

[root@aap21 ~]# ansible-galaxy collection install community-aws-3.1.0.tar.gz 
Starting galaxy collection install process
Process install dependency map
[WARNING]: Skipping Galaxy server https://galaxy.ansible.com/api/. Got an unexpected error when getting available versions of collection amazon.aws: Unknown error when
attempting to call Galaxy at 'https://galaxy.ansible.com/api/v2/collections/amazon/aws/': <urlopen error [Errno 101] Network is unreachable>
ERROR! Unknown error when attempting to call Galaxy at 'https://galaxy.ansible.com/api/v2/collections/amazon/aws/': <urlopen error [Errno 101] Network is unreachable>
```


### Expected Results

```yaml
[root@aap21 ~]# ansible-galaxy collection install amazon-aws-3.1.1.tar.gz 
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Installing 'amazon.aws:3.1.1' to '/root/.ansible/collections/ansible_collections/amazon/aws'
amazon.aws:3.1.1 was installed successfully <====

[root@aap21 ~]# ansible-galaxy collection install community-aws-3.1.0.tar.gz 
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Installing 'community.aws:3.1.0' to '/root/.ansible/collections/ansible_collections/community/aws'
community.aws:3.1.0 was installed successfully
'amazon.aws:3.1.1' is already installed, skipping. <=====
```


### Actual Results

```console
[root@aap21 ~]# ansible-galaxy collection install amazon-aws-3.1.1.tar.gz 
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Installing 'amazon.aws:3.1.1' to '/root/.ansible/collections/ansible_collections/amazon/aws'
amazon.aws:3.1.1 was installed successfully <====

[root@aap21 ~]# ansible-galaxy collection install community-aws-3.1.0.tar.gz -vvvv
ansible-galaxy [core 2.12.0]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-galaxy
  python version = 3.8.6 (default, Jan 22 2021, 11:41:28) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
  jinja version = 2.10.3
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
Starting galaxy collection install process
Found installed collection amazon.aws:3.1.1 at '/root/.ansible/collections/ansible_collections/amazon/aws'
Process install dependency map
Initial connection to galaxy_server: https://galaxy.ansible.com
Found API version 'v1, v2' with Galaxy server default (https://galaxy.ansible.com/api/)
Opened /root/.ansible/galaxy_token
Calling Galaxy at https://galaxy.ansible.com/api/v2/collections/amazon/aws/
[WARNING]: Skipping Galaxy server https://galaxy.ansible.com/api/. Got an unexpected error when getting available versions of collection amazon.aws: Unknown error when
attempting to call Galaxy at 'https://galaxy.ansible.com/api/v2/collections/amazon/aws/': <urlopen error [Errno -2] Name or service not known>
ERROR! Unknown error when attempting to call Galaxy at 'https://galaxy.ansible.com/api/v2/collections/amazon/aws/': <urlopen error [Errno -2] Name or service not known>
```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct
to_text(output_path, errors='surrogate_or_strict'),
                        force=True,
                    ),
                    errors='surrogate_or_strict',
                )
            else:
                shutil.copy(to_native(b_src_path), to_native(b_dest_path))
            display.display(
                "Collection '{coll!s}' was downloaded successfully".
                format(coll=concrete_coll_pin),
            )
            requirements.append({
                
                
                
                
                
                
                'name': to_native(os.path.basename(b_dest_path)),
                'version': concrete_coll_pin.ver,
            })
        requirements_path = os.path.join(output_path, 'requirements.yml')
        b_requirements_path = to_bytes(
            requirements_path, errors='surrogate_or_strict',
        )
        display.display(
            u'Writing requirements.yml file of downloaded collections '
            "to '{path!s}'".format(path=to_text(requirements_path)),
        )
        yaml_bytes = to_bytes(