Pretty much never...

I think the best way is to compare mathematics to a natural language, and the equivalent question is "When is language NOT about spelling?".

Counting is to spelling, as algebra is to making sentences, as proofs are to essays.

You can figure out the answer from there.

There are very complicated ways of "counting", when it comes to infinities, combinatorics and so on, but most questions that math solves revolve around a finite set of basic rules, most which don't involve "measure", but rather an abstract, yet (hopefully) intuitive concept. These are called axioms. Would you say that the statemet "two lines may never meet" is a form of "measure" ? It is however mathematical statement, an we define such lines as parallel(orthagonal in higher dimension). 

Would you say that the proof thereof, or the conditions for this to happen from geometry/cartesian algebra is some sort of counting?
The answer is probably no.

All the examples you gave are merely math *applied* to physics and the real world, math does cater only to the real world, and for the most part, it does not care about units.

For example, the idea that there are infinetly many primes uses (unitless) numbers, logic and properties of these to add a new fact to a knowledge-base which was built on these axioms.

So to answer your question, very little of math is actually about "counting".