Let $\varphi: A \times B \to C \times D$ be the isomorphism.
Then, $\varphi(A \times \{0\})$ is an ideal of $C \times D$.
By the structure theorem for ideal of product, $\varphi(A)$ can be expressed in the form $\mathfrak c \times \mathfrak d$, where $\mathfrak c$ and $\mathfrak d$ are ideals of $C$ and $D$ respectively.
If they are both not zero, then letting $\varphi(a_c,0) \in C \times \{0\}$ and $\varphi(a_d,0) \in \{0\} \times D$ be the non-trivial elements, we see that $\varphi(a_c a_d, 0) = 0$, so $a_c = 0$ or $a_d = 0$, contradiction.
Therefore, either $\mathfrak c = 0$ or $\mathfrak d = 0$. In the first case, $A \cong D$; in the second case, $A \cong C$.