José's solution is nice. And I agree with his assessment that an error you made is that you didn't explain why $g(x)$ is a polynomial. To see the error consider the following piece of faulty reasoning:
A False Fact. If $f(1)=0$ then $(x-1)^2\mid f(x)$.
Proof.
Write
$$
\frac{f(x)-f(1)}{(x-1)^2}=g(x).
$$
Because $f(1)=0$ we see that
$$
\frac{f(x)}{(x-1)^2}=g(x).
$$
If your logic were valid, we could conclude that $(x-1)^2\mid f(x)$. But this result is clearly false in general. For example when $f(x)=x^2-1$ we have $f(1)=0$, but $(x-1)^2\nmid (x^2-1)$.
You can also do the following.
Let
$$
f(x)=a_0+a_1x+\cdots+a_mx^m,
$$
where $m$ is the degree of $f$. Then
$$
f(x^n)=a_0+a_1x^n+\cdots+a_mx^{nm}.
$$
We are given that $x-1\mid f(x^n)$. This means that $x=1$ is a zero of $f(x^n)$, or that $0=a_0+a_1+\cdots+a_m.$
But then
$$
\begin{aligned}
f(x^n)&=f(x^n)-f(1)\\
&=a_0(1-1)+a_1(x^n-1)+a_2(x^{2n}-1)+\cdots+a_m(x^{mn}-1).
\end{aligned}
$$
Here all the binomials $x^{kn}-1$, $k=0,1,\ldots,m$, are divisible by $x^n-1$. Hence so is $f(x^n)$.