find the $Var[X(t)]$, where $X(t)=\sum_{i=0}^{N(t)}Y_i$ , $N(t)$ is Poisson process and $Y_i$ is IIDRV the answer is $E[N(t)]Var[Y_1]+E^2(Y_1)Var[N(t)]$.
but I get this:
$$
Var[X(t)]=E[X^2(t)]-(E[X(t)])^2=E[N^2(t)]E[Y_i^2]-E^2[N(t)]E^2[Y_1]$$
where:
$$
E[X(t)]=E[E[\sum_{i=0}^{N(t)}Y_i|N(t)=n]]=E[N(t)]E[Y_1]\\
E[X^2(t)]=E[E[(\sum_{i=0}^{N(t)}Y_i)^2|N(t)=n]]=\sum_{n=0}^{\infty}n^2E[Y_i^2]P(N(t)=n)=E[N^2(t)]E[Y_i^2]
$$
Am I wrong? how to get the correct result?

Your calculation for $\mathbb{E}[X^2(t)]$ is not quite right – when you expand out the square, you would also get the cross terms, e.g. $\mathbb{E}[Y_i Y_j]$, $i \ne j$.
Analogous to the computation of $\mathbb{E}[X(t)]$ – which uses the law of total expectation -- there is a version for variances:
$$
\mathrm{Var}(X(t)) = \mathbb{E}[\mathrm{Var}(X(t) \mid N(t))] + \mathrm{Var}(\mathbb{E}[X(t) \mid N(t)]) .
$$
(Can you prove this?) If you use this result instead, you should be able to obtain $\mathrm{Var}(X(t))$ using similar arguments that you already have used.
