The expected squared increment of a continuous local martingale Suppose $M=\{ M_t\}_{t\geq 0}$ is a continuous local martingale, and $M_0=0$. Then I often see the following equation
$$\mathbb{E}M_t^2=\mathbb{E}\sum_i(M_{t_{i+1}}^2-M_{t_i}^2)=\mathbb{E}\sum_i(M_{t_{i+1}}-M_{t_i})^2.$$
I am new to stochastic analysis, so the second equation really puzzles me. If we expend the last expression in traditional way, certainly $M_{t_{i+1}}^2-M_{t_i}^2\neq(M_{t_{i+1}}-M_{t_i})^2$. So how does it work?

While it certain isn't true that $M_{t_{i+1}}^2 - M_{t_i}^2 = (M_{t_{i+1}} - M_{t_i})^2$, their expectations are the same. To see this, first assume that $M$ is a martingale, and use the tower property for conditional expectations:
$$\begin{align*}
\mathbb{E}[(M_{t_{i+1}} - M_{t_i})^2] &= \mathbb{E}(M_{t_{i+1}}^2) - \mathbb{E}[\mathbb{E}(2M_{t_{i+1} M_{t_i}} \, | \, \mathcal{F}_{t_i})] + \mathbb{E}(M_{t_{i}}^2) & \text{(tower property)}\\
&= \mathbb{E}(M_{t_{i+1}}^2) - 2\mathbb{E}[M_{t_i}\mathbb{E}(M_{t_{i+1} } \, | \, \mathcal{F}_{t_i})] + \mathbb{E}(M_{t_{i}}^2) & (M_{t_i} \text{ is }\mathcal{F}_{t_i}\text{-measurable}) \\
&= \mathbb{E}(M_{t_{i+1}}^2) - 2\mathbb{E}[M_{t_i}^2] + \mathbb{E}(M_{t_{i}}^2) & (\mathbb{E}(M_{t_{i+1} } \, | \, \mathcal{F}_{t_i}) = M_{t_i}) \\
&= \mathbb{E}(M_{t_{i+1}}^2 - M_{t_i}^2)
\end{align*}$$
If $M$ is a local martingale, let $(\tau^n)$ be a localising sequence of stopping times (i.e. the processes $M_{t\land \tau^n}$ are martingales and $\tau^n \to \infty$ almost surely); then:
$$\begin{align*}
\mathbb{E}[(M_{t_{i+1}} - M_{t_i})^2] &= \lim_{n \to \infty} \mathbb{E}[(M_{t_{i+1} \land \tau^n} - M_{t_i\land \tau^n})^2] \\
&= \lim_{n \to \infty }\mathbb{E}(M_{t_{i+1} \land \tau^n}^2) - \mathbb{E}(M_{t_{i} \land \tau^n}^2)  \\
&= \mathbb{E}(M_{t_{i+1}}^2 - M_{t_i}^2)
\end{align*}$$
