Suppose $A,B$ are connected. To show that $A\times B$ is also connected, it suffices to show that any continuous map $f: A\times B\to \{0,1\}$ is constant. Let's do this right away.
Consider some continuous map $f: A\times B\to \{0,1\}$, and fix $(a_1,b_1) \in A\times B$. Now define $g: A\to\{0,1\}$ so that $g:a\mapsto f(a,b_1)$, and $h:B\to\{0,1\}$ so that $h: b\mapsto f(a_1,b)$. Since $A,B$ are connected, $g$ and $h$ must be necessarily constant. So, $f(a_1,b) = f(a,b_1) = f(a_1,b_1)$ for all $(a,b)\in A\times B$.
Now, fix some other $(a_2,b_2)\in A\times B$, i.e. $(a_1,b_1) \ne (a_2,b_2)$. Repeat the same process as above to obtain $f(a_2,b) = f(a,b_2) = f(a_2,b_2)$ for all $(a,b)\in A\times B$.
In $f(a_1,b) = f(a_1,b_1)$, put $b = b_2$ to get $f(a_1,b_1) = f(a_1,b_2)$. In $f(a,b_2) = f(a_2,b_2)$ put $a = a_1$ to get $f(a_2,b_2) = f(a_1,b_2)$.
This gives $$f(a_1,b_1) = f(a_2,b_2)$$
The choice of $(a_1,b_1)$ and $(a_2,b_2)$ was arbitrary, so indeed $f(a_1,b_1) = f(a_2,b_2)$ for all $(a_1,b_1), (a_2,b_2) \in A\times B$. $f$ is a constant function. Done! $\ \ \blacksquare$
This can be generalized! If $A_1,A_2,\ldots,A_n$ are connected, then so is $A_1\times A_2\times \ldots\times A_n$. You can see this in at least two ways. One, try using induction on $n$, and the result we proved above for $n=2$. $n=2$ is also the base case of induction. Alternatively, you may prove this from scratch by a similar procedure, i.e. selecting $(a_1^{(k)},a_2^{(k)},\ldots,a_n^{(k)}) \in A_1\times A_2\times \ldots\times A_n$ for $k=1,2,\ldots,n$. This is more cumbersome and might be difficult to follow, but the essence remains the same!
Food for Thought:
At this point, I wonder if this can be extended to arbitrary products - i.e. if $\{A_i\}_{i\in I}$ constitute a collection of connected sets, is $\prod_{i\in I} A_i$ also connected? (The answer is Yes).