Given a continuously differentiable function $f : U \subset \mathbb{R}^n \mapsto \mathbb{R}^m$ (where $U$ is an open set), we say that $x$ is a critical point of $f$ if $Df(x)$ is not full rank. Let $C_f$ represent the set of all critical points of $f$. From Sard's theorem, we know that when $f$ satisfies certain regularity conditions, then $ f(C_f) $ has measure $0$ in $\mathbb{R}^{m}$. A generalisation of this result states that (again, under suitable regularity) if $ A_r = \{ x \in \mathbb{R}^n \mid \text{rank}Df(x) < r \} $, then the Hausdorff dimension of $ f(A_r) $ is at most $r$, but it can be arbitrarily close to $r$.
My question is, (*) what 'nice' functions are known to have the property that $ f(C_f) $ is actually always a countable set?
For example, I think that this (*) would hold when $f : U \mapsto \mathbb{R}^m $ is analytic and $C_f \neq U$.
Also, in the case when $m=1$ and $C_f$ is a connected set, although we might expect that $f$ will be constant on $C_f$, Whitney constructed a real-valued $C^1$ function of $2$ variables such that $C_f$ is an arc and $f(C_f)$ is not a constant and in fact contains an open set of $\mathbb{R}$. The same paper mentions that when $f$ is 'smooth enough', then "$f$ must be constant on any connected critical set, as shown by M. Morse and A. Sard in an unpublished paper". But in my view, this shows that it is quite difficult to come up with such functions and I would expect 'generic' functions (in some appropriate sense) to be constant on each connected set of critical points, even given lower regularity.
Any thoughts or references regarding this are welcome!
Consider the polynomial function $$ f(x,y)=(x,y^2). $$ Then the set of critical values of $f$ is uncountable, equal to $$ \{(x,0): x\in {\mathbb R}\}. $$ Hence, your conjecture about real-analytic functions fails.
On the other hand, if $f: U\to {\mathbb R}$ is a real-analytic function defined on an open connected subset $U\subset {\mathbb R}^n$, then the set of critical values of $f$ is countable, see e.g. here.