Default services not being accessible when using includes

I have a standard gitlab-ci that looks like this (simplified version)

.gitlab-ci.yml

include:
  - .base.yml
  - .mariadb.config.yml

job:
  script:
    - mysql -u root -h db -e 'Some SQL statement'
    - <other commands>

.base.yml

variables:
  DEBIAN_FRONTEND: 'noninteractive'

default:
  image: 'php:7.4'
  before_script:
    - 'mkdir -pv /usr/share/man/man1 /usr/share/man/man3 /usr/share/man/man7'
    - '( apt-get -qq update && apt-get -yqq install --no-install-suggests default-jre-headless mariadb-client )'

.mariadb.config.yml

variables:
  FF_NETWORK_PER_BUILD: 'true'
  DB: 'mariadb'

default:
  services:
    - name: 'mariadb:10.6'
      alias: 'db'
      command:
        - '--character-set-server=utf8mb4'
        - '--collation-server=utf8mb4_unicode_ci'
        - '--innodb_file_per_table=On'
        - '--wait-timeout=28800'
        - '--skip-log-bin'
      variables:
        MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 'yes'

I would like to connect to the database with mysql client and do some stuff but all I get is:

ERROR 2005 (HY000): Unknown MySQL server host 'db' (-2)

If I merge all these parts in main .gitlab-ci.yml everything works as expected. What am I doing wrong here?