$\newcommand{\id}{\operatorname{Id}_{TM}}$ Let $M$ be a smooth connected closed Riemannian manifold.
Let $X$ be a vector field on $M$, and suppose that $\nabla X=h \cdot \id$, for some $h \in C^{\infty}(M)$.
Is it true that $h$ is constant? ($\nabla$ is the Levi-Civita connection on $M$).
This is true when the curvature of $M$ is zero. Indeed, we can consider $\nabla X$ as a one form on $M$ with values in $TM$: $\nabla X \in \Omega^1(M,TM)$. Then
$$R_{\nabla} (\cdot,\cdot)X=d_{\nabla}^2X=d_{\nabla}\nabla X =d_{\nabla}(h \cdot \id). \tag{1}$$
Using Leibnitz rule, $$ d_{\nabla}(h \cdot \id)=h d_{\nabla} \id-dh \wedge \id=-dh \wedge \id. \tag{2}$$
(We used here the fact $\nabla$ is torsion-free and $d_{\nabla} \id$ is the torsion).
Combining equations $(1),(2)$, we obtain
$$ R_{\nabla} (\cdot,\cdot)X=-dh \wedge \id.$$ When $R=0$, this means $dh \wedge \id=0$, i.e $$ dh(v_1)v_2-dh(v_2)v_1=0$$ for all $v_1,v_2 \in \Gamma(TM)$. This implies $dh=0$, so $h$ is constant.
(In fact, so far we have only used torsion free and $R=0$, with no use of metricity).
$\newcommand{\id}{\operatorname{Id}_{TM}}$No. As a counterexample we can take the vector field $X = \sin(\theta) \partial_\theta$ on the two-sphere with the standard metric $g = d \theta^2 + \sin(\theta)^2 d\varphi^2.$ Near the north pole this looks like the homothetic vector field $X(x) = x$ on $\mathbb R^2$, while near the south pole it looks like $X(x) = -x.$
A coordinate calculation shows that $\nabla X = \cos(\theta)\id,$ since the only non-zero Christoffel symbols are $\Gamma^\theta_{\varphi\varphi} = -\sin \theta \cos \theta$ and $\Gamma_{\theta\varphi}^\varphi = \cos \theta / \sin \theta.$