We know that sum of two subrings need not be a subring, but then why is the following so:
Let $A$ be a subring of a ring $R$ and $I$ an ideal of $R$ . Then $A+I=\{a+i\mid a\in A,i\in I\}$ is a subring of $R$.
This was written in statement for second homomorphism theorem, but I can't understand why is $A+I$ a subring.
Let $R$ denote a not-necessarily commutative ring. Assume that $A \subseteq R$ is a subring and that $I \subseteq R$ is a two-sided ideal.
Let us show that $A+I$ is closed under products, since closure under addition is trivial, and so too is closure under unary negation (by which I mean the function $x \in R \mapsto -x \in R$). So suppose $x,y \in A+I$. Then $x=a+i$ and $y=a'+i'$ for appropriate choices of $a,a' \in A$ and $i,i' \in I$. So
$$xy = (a+i)(a'+i') = \underbrace{aa'}_{\in A}+\underbrace{ia'+ai'+ii'}_{\in I} \in A+I$$
So $A+I$ is closed under products.
We can write the above argument in more compact notation as follows:
$$(A+I)(A+I) = \underbrace{AA}_{\subseteq A}+\underbrace{IA+AI+II}_{\subseteq I} \subseteq A+I$$
Remark. If $R$ has a unity element $1,$ and if $1 \in A,$ then since $1+0 \in A+I$, hence $1 \in A+I$.