Docker comopse profile

How do you do?

I have the following problem:
I have the following compose.yaml file here:

services:
  server:
    build:
      context: .
      target: production
    image: ${DOCKER_HUB_USERNAME}/todo-list
    environment:
      NODE_ENV: production
      MYSQL_HOST: ${MYSQL_HOST}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
    ports:
      - 8000:8000
    depends_on:
      mysql:
        condition: service_healthy
    volumes:
      - .:/usr/src/app
      - /usr/src/app/node_modules
  test:
    build:
      context: .
      target: test
    environment:
      NODE_ENV: test
      MYSQL_HOST: ${MYSQL_HOST}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
    ports:
      - 8000:8000
    depends_on:
      mysql:
        condition: service_healthy
    profiles:
      - test
  mysql:
    image: mysql:latest
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - todo-mysql-data:/var/lib/mysql
    expose:
      - 3306

volumes:
  todo-mysql-data:

When I run docker compose --profile test up, server is also started, although test does not depend on server and server does not belong to the profile test. What is the reason for this? I am working with Windows 11 and Docker Desktop.

I think target does not do what you expect (doc):

target defines the stage to build as defined inside a multi-stage Dockerfile.

From ChatGPT:

Within the build context, you can specify a target. This target corresponds to a build stage in your multi-stage Dockerfile. By defining a target, you instruct Docker Compose to build the image up to a certain stage in the multi-stage process.