Let $f: X\to Y$ be a flat morphism between smooth complex affine varieties. Let $Z$ be the closed set of most singular points of $f$ (in the sense: $p$ is a most singular point of $f$ if the tangent map $Tf_p$ at $p$ has the lowest rank among the closed points in $X$). Denote $r:=\text{rank} Tf_p$ for $p\in Z$. Is it true that $\text{dim}f(Z)=r$ (generic smooth theorem tells us it is $\leq r$). If not in general, is there a quick example for $\text{dim}f(Z)<r$?

Newly updated: Is there a counterexample for proper flat morphism $f: X\to Y$ between smooth complex manifolds $X$ and $Y$?