That is a common problem with first generation Mazda2s. It's only happening on the cars with the automatic AC. The "thing" that is making that clicking noise is actually as big as box of matches. It's the unit with a small electric motor and a plastic cogwheel that is opening and closing the airflow from outside. That explains why it's making that noise every time you switch the airflow. The plastic cogwheel just worn out. So the only way to fix it is to switch the plastic one with a metal one or with a better quality plastic cogwheel.
If someone needs help how to find that box. I can post pictures