Let $G_1$, $G_2$ be groups of prime power order.
Write $|G_1|=p^m$ and $|G_2|=q^n$ for some $0 \leq m,n$. (The primes $p,q$ need not be distinct.)
Let $H_1$ be a subgroup of $G_1$ and let $H_2$ be a subgroup of $G_2$.
Necessarily, $|H_1|=p^r$ and $|H_1|=q^s$ for some $0 \leq r \leq m$ and $0 \leq s \leq n$.
Is the group $H_1 \times H_2$ a subgroup of $G_1 \times G_2$ having order $p^r q^s$ and index $p^{m-r} q^{n-s}$?
Yes, the order is just the number of elements of the group and the index is the order of the larger group divided by the order of the subgroup for finite groups. So you just need to show that $H_1 \times H_2$ is a subgroup.