I am trying to understand this computation of the class group of $\Bbb Q(i)$.
I don't understand why $2\mathcal O_K=(1+i)^2$. I don't know how to calculate $\mathcal O_K$, I know it's hard in general.
Any hint/help in the right direction is appreciated.

Here's a fairly systematic approach:
Let $k = \Bbb Q[\alpha]$ where $m_\alpha(x)$ is the minimal polynomial of $\alpha$.
Then Dedekind's Criterion says that, assuming $m_\alpha(x) \equiv m_1^{e_1}(x)\cdots m_g^{e_g}(x) \mod p$ for irreducible $m_i$, we have $(p) = Q_1^{e_1}\cdots Q_g^{e_g}$ where $Q_j = (m_j(\alpha), p)$ and the $Q_j$ are prime.
In our case $\alpha = i$ and $m_\alpha(x) = x^2 + 1$.
We see that $(2) = (i+1, 2)^2$.
Now obviously $(i+1) \subseteq (i+1, 2)$ and since $-i \cdot (i+1)^2 = 2$, we have the converse too: $(i+1) = (i+1, 2)$.
Therefore $(2) = (i+1)^2$.