Solution (source code)

= Solution

One form of the <Mumford rigidity lemma> says that if $X$ is a complete variety, $S$ is connected, and a morphism $F:X\times S\to Z$ maps $X\times\{s_0\}$ to one point, then $F$ factors through the projection to $S$. In particular, if $F$ also maps $\{x_0\}\times S$ to that point, then $F$ is constant.

Choose $s_0\in S(k)$ and put $g=f|_{X\times\{s_0\}}$. To see that the pointed morphism $g:X\to Y$ is a homomorphism, apply rigidity to
$$
D(x_1,x_2)=g(x_1+x_2)-g(x_1)-g(x_2).
$$
It vanishes on $X\times\{e\}$, so it factors through the second projection; it also vanishes on $\{e\}\times X$, so it is identically zero. Now define
$$
F(x,s)=f(x,s)-g(x).
$$
Then $F(x,s_0)=e$ for every $x$ and $F(e,s)=e$ for every $s$. Rigidity forces $F$ to be identically $e$, so
$$
\boxed{f|_{X\times\{s\}}=g\in\operatorname{Hom}_k(X,Y)\quad\text{for every }s\in S(k).}
$$