"Town C is 345 km nearer to Town A than Town B" means that the distance between Town C and Town A is 345 km less than the distance between Town C and Town B. The other version is understandable, but nobody would ever say it that way. It's longer than it needs to be.
"The air is fresher in the mountains than cities" is, strictly speaking nonsense. It sounds as if you're comparing air to cities, when in fact you want to compare the air in mountains to the air in cities; so the second version is better.