Pipeline conditions not working

I am trying to create a terraform pipeline which runs stage Test - on all branches, all commits
Plan - when a Merge req is created
Deploy - when someone approves Merge request.

below is my ci file

stages:
  - test
  - plan
  - deploy

image:
  name: hashicorp/terraform:0.11.14
  entrypoint: [ "" ]

lint:
  stage: test
  script:
    - terraform fmt -diff=true -check

.test:
  stage: test
  before_script: [ *terraform ]
  script:
    - terraform validate -check-variables=false
  only:
    changes:
      - providers/** 
      - modules/**
    refs:
      - merge_requests


.plan: &plan
  stage: plan
  before_script: *install
  script:
    - terraform plan --out=${CATALOG_NAME}
  artifacts:
    paths:
      - 'catalog_*'
    expire_in: 1d
  only:
    changes:
      - providers/** 
      - modules/**
    refs:
      - merge_requests



.deploy:
  <<: *plan
  stage: deploy
  environment:
    name: "${CI_JOB_NAME}"
  script:
    - terraform apply -auto-approve ${CATALOG_NAME}
  artifacts: {}
  only:
    refs: [ master ]
    changes:
      - providers/** 
      - modules/**

I call this pipeline as below

   include -abovefile

    teamname:
      extends: .test
      only:
    changes:
      - providers/alerts/teamname/* 
      - modules/**
    refs:
      - merge_requests

teamname:
  extends: .plan
  only:
    changes:
      - providers/alerts/teamname/* 
      - modules/**
    refs:
      - merge_requests

teamname:
  extends: .deploy
  only:
    changes:
      - providers/alerts/teamname/* 
      - modules/**
    refs:
      - master
  • What are you seeing, and how does that differ from what you expect to see?

It does only lint on the branches
It does only lint on the merge requests

Can someone please help