Suppose you have a ring $R$, and $\mathfrak a,\mathfrak b$ are ideals with $\mathfrak a+\mathfrak b=1$, that is, they are comaximal. Then we can find $a,b\in\mathfrak a,\mathfrak b$ resp. with $a+b=1$. Then $a^2+2ab+b^2=1$, and $a^2\in\mathfrak a^2$, $2ab+b^2\in \mathfrak b$. This means $\mathfrak a^2+\mathfrak b=1$. Doing the same with this, we obtain $\mathfrak a^2+\mathfrak b^2=1$, (i.e. apply the last with $\mathfrak a'=\mathfrak a^2$). If $\mathfrak a=(a)$ and $\mathfrak b=(b)$, we get your result.
Of course, we can generalize this to any $m,n$ to get $\mathfrak a^m+\mathfrak b^n=1$. A related situation is true: if the radicals of $\mathfrak a,\mathfrak b$ generate the whole ring, then in fact $\mathfrak a,\mathfrak b$ generate the whole ring. If we have an equation $x+y=1$; and if $x^n\in \mathfrak a,y^n\in\mathfrak b$, show by means of the binomial theorem that $(x+y)^{n+m}=1$ can be written as a sum $A+B=1$ where $A\in\mathfrak a,B\in\mathfrak b$.