Follow these steps
Open your terminal and run this bellow command
sudo nano ~/.bash_profile
export PATH=/Applications/MAMP/bin/php/php7.4.21/bin:$PATH
Save this file
Run below command
source ~/.bash_profile
Now check your PHP version in terminal
php --version
sudo nano ~/.zshrc
Then change version
export PATH=/Applications/MAMP/bin/php/php7.3.29/bin:$PATH
source ~/.zshrc