Suppose we have two random variables $A$ and $B$ both uniformly distributed on $[0, 1]$. Define $Z=A+B$.
The moment generating function of $A$ and $B$ is $M_A(\theta)=M_B(\theta)=\frac{e^{\theta}-1}{\theta}$, so $M_Z(\theta)=M_A(\theta) M_B(\theta)=(\frac{e^{\theta}-1}{\theta})^2 = \frac{e^{2\theta}-2e^{\theta}+1}{\theta^2} $.
On the other hand the probability density function of $Z$ is $f_Z(z)=z$ for $z<1$ so we should have $M_Z(\theta)=E[e^{Z\theta}]=\int_0^1e^{z\theta}f_Z(z) \space dz= \int_0^1e^{z\theta}z \space dz = \frac{e^{\theta} \theta - e^{\theta} + 1}{\theta^2}$.
Can someone please explain me where does the difference of answers come from?
Why would that be the case? $Z$ is not uniform, it has a triangular distribution with parameters $a=0$, $b=2$ and $c=1$. You can check the MGF matches.
To get back the result with your computations: $f_Z$ is actually $$ f_Z(z) = z\mathbb{1}_{[0,1]}(z) - (2-z)\mathbb{1}_{[1,2]}(z) $$ (note that your proposed expression would integrate to $1/2$, not to $1$!). You can check that $$ \int_{0}^1 e^{z\theta}z \, dz + \int_{1}^2 e^{z\theta}(2-z) \, dz = \frac{(e^\theta-1)^2}{\theta^2} $$ as it should.