Consider any pair of sequences $(a_n) \subset A$ and $(b_n) \subset B.$ The sequence $((a_n),(b_n)) \subset A \times B$ is contained in $A \times B.$ Hence, there is a subsequence $(a_{f(n)}, b_{g(n)}) \subset A \times B$ whose limit $(a',b') \in A \times B.$ It follows that $(a_{f(n)}) \subset (a_n) \subset A$ and $(b_{g(n)}) \subset (g_n) \subset B,$ that is, $(a_{f(n)})$ is a subsequence of the sequence $(a_n),$ which is contained in $A,$ and $(b_{g(n)})$ is a subsequence of the sequence $(b_n),$ which is contained in $B.$ Moreover, it also follows from $(a',b') \in A \times B$ that $a' \in A$ and $b' \in B.$ Therefore, the subsequences $(a_{f(n)})$ of $(a_n) \subset A$ and $(b_{g(n)})$ of $(b_n) \subset B$ have their limits $a'$ and $b',$ respectively, in $A$ and $B,$ respectively. Hence, $A$ and $B$ are compact.
Is there something missing in this proof?
Definition of compactness in the textbook:
"A subset $A$ of a metric space $M$ is (sequentially) compact if every sequence $(a_n)$ in $A$ has a subsequence $(a_{n_k})$ that converges to a limit in $A.$
This is the only definition of compactness mentioned in the textbook.
It's fine as long as you are working in spaces in which sequentially compact $\Leftrightarrow$ compact, e.g metrizable spaces. But this is also true for more general spaces. Indeed, when $A\times B$ has the product topology, the maps $\pi_A: A\times B \rightarrow A$, $\pi_B: A\times B \rightarrow B$ defined as the projections are continuous. Since continuous maps send compact to compact, then $A=\pi_A(A\times B)$, $B=\pi_B(A\times B)$ are both compact.