Probably a trivial mistake, but can't seem to spot it:
Assume $X_1, \ldots, X_\tau$ and $\tau \in \{1, \ldots, n\}$ are random i.i.d variables, where $S_\tau = X_1 + \ldots + X_\tau$ denotes the random sum.
It can be shown that the following holds:
$$Var(S_\tau | \tau )=\tau Var(X_1)$$
However, from what I know,
$$Var(S_\tau | \tau) = \mathbb{E}( (S_\tau - \mathbb{E}(S_\tau|\tau))^2|\tau) = \mathbb{E}(S_\tau^2|\tau) - \tau^2\mathbb{E}(X_1)^2$$
Here $$ \mathbb{E}(S^2_\tau|\tau)=\mathbb{E}((X_1+\ldots+X_\tau)^2|\tau)=\sum_{i,j}^{n}\mathbb{E}(X_iX_j|\tau)\mathbb{1}_{\{i,j\leq \tau\}}=\mathbb{E}(X_1^2)\tau^2$$ due to independency and identical distributions.
So with my calculations I'm getting $$Var(S_\tau|\tau)=\tau^2 Var(X_1)$$
and I'm not sure where should the squared $\tau$ disappear.
I seem to be missing something, but can't spot it.
Would be grateful for any observations!
First of all, $\mathbb{E}[X_iX_j] = \mathbb{E}[X_i]\mathbb{E}[X_j] = (\mathbb{E}[X_1])^2 \ne \mathbb{E}[X_1^2]$
Also, there will be $\tau$ terms of $X_i^2$ and $\tau(\tau-1)$ terms of $X_iX_j$ in the expansion of the square. Therefore your second equation will become
$$\mathbb{E}(S^2_\tau|\tau)=\mathbb{E}((X_1+\ldots+X_\tau)^2|\tau)=\sum_{i,j}^{n}\mathbb{E}(X_iX_j|\tau)\mathbb{1}_{\{i,j\leq \tau\}}=\mathbb{E}(X_1^2)\tau + \tau(\tau-1)(\mathbb{E}[X_1])^2$$
$$Var(S_\tau|\tau)=\mathbb{E}(X_1^2)\tau + \tau(\tau-1)(\mathbb{E}[X_1])^2 - \tau^2\mathbb{E}(X_1)^2$$
$$= \tau\mathbb{E}(X_1^2) -\tau(\mathbb{E}[X_1])^2 $$
$$= \tau(\mathbb{E}(X_1^2)-(\mathbb{E}[X_1])^2)$$
$$=\tau Var(X_1)$$