Thermoacidophiles are a class of bacteria, who can survive in extreme conditions.
One of the qualities of few bacteria in these classes is the ability to survive in both aerobic and anaerobic conditions.
We know that aerobic pathway is better. Aerobic respiration, can give more ATP, ie, more energy , but anaerobic respiration is less efficient, and gives lesser energy.
So, when oxygen is available, they use oxygen and conduct aerobic respiration , so living aerobically, and when oxygen is absent, they use anaerobic pathway for respiration.
You will learn about these pathways in biology, in chapter respiration in class 12. Both these pathways are different. When you actually learn these pathways, you can actually understand how it occurs.
Note: All Thermoacidophiles are not both aerobic and anaerobic.
Some are aerobic, some are anaerobic, and a few specially evolved ones have ability to do both. These characters are a result of evolution.
So , for now, just understand that the bacterial cell decides how to work, and accordingly chooses best path.