Consider of sequence of i.i.d. Bernoulli trials with the success parameter $p$. Let $X$ be the first time we get a success, and let $Y$ be the random variable determined if the first time is successful or not.
Then $X \sim Geo(p)$ and $Y \sim Bern(p)$. I need to find $E(X^2|Y=0)$.
I find another question that is relevant to my question, here
But I don't understand why we get $E(X^2|Y=0) = E((1+X)^2)$. Why we get this?
I'm very grateful to any help and answers.
It is important to be clear about what $Y$ indicates in your link.
$$Y=\begin{cases}1 &:& X=1\\[1ex] 0 &:& X> 1\end{cases}$$ Recall too that geometric distributions are memoryless.
$$\mathsf P(X=s\mid X=1)=\mathsf P(X=s-1)$$
So $$\begin{align}\mathsf E(X^2\mid Y=0) ~&=~ \mathsf E(X^2\mid X>1)\\[1ex] &=~\sum_{n>1} n^2\,\mathsf P(X=n\mid X>1)\\[1ex]&=~\sum_{n>1} n^2\,\mathsf P(X=n-1)\\[1ex]&=~\sum_{m\geq 1} (m+1)^2\,\mathsf P(X=m)\\[1ex]&=~\mathsf E((X+1)^2)\end{align}$$