You generally use the definite article the when you are referring to a specific thing and both you and the listener/reader understand which particular thing you are talking about. This is the case in the answer that you referred to: the answerer is talking about "all of the air surrounding the planet".
When talking about a thing in general, we don't use the definite article. if it's a mass noun (air, water, sugar) we don't use an indefinite article either.
Compare these two sentences:
I don't like the cheese.
I don't like cheese.
The first sentence refers to a particular piece of cheese and the speaker/writer and the listener/reader both know what particular piece of cheese this refers to. The second sentence refers to cheese in general: the speaker/writer does not like cheese of any sort.
When talking about air in a scientific context, we are usually talking about air as a medium- air in general. We therefore do not use the definite article, although it would be grammatically correct to do so since, as far as this planet is concerned, air in general is the same as the air that surrounds our planet.
Looking at typical actual usages of air in a scientific context, for example as search for "[speed] of sound in air" vs. "[speed] of sound in the air", google NGrams finds very few instances where the air is used, and generally they are references to a specific volume or type of air, for example "the speed of sound in the air in the tube".