I will first state the characterization of the subgroup of a direct product. Then I will try to make this characterization seem at least a bit intuitive by explaining what sorts of subgroups it gives. Finally, I will demonstrate how to use it for finding the number of subgroups of $\mathbb{Z}/p^2\mathbb{Z}\times\mathbb{Z}/p^2\mathbb{Z}$.
The characterization says the following: Let $G$ and $H$ be groups. Then the subgroups of $G\times H$ are in bijection with the set of $5$-tuples $(G_1,G_2,H_1,H_2,\varphi)$ where $G_2\unlhd G_1\leq G$, $H_2\unlhd H_1\leq H$ and $\varphi: G_1/G_2\to H_1/H_2$ is an isomorphism.
The correspondence is given by assigning to such a tuple the subgroup $\{(g,h)\in G_1\times H_1\mid \varphi(gG_2) = hH_2\}$.
So let us take a look at what sort of subgroups we can construct "naively" in the direct product, and try to put them on the form above.
First, we have those of the form $G_1\times H_1$ (these are the easiest one to think of). These correspond to picking $G_2 = G_1$ and $H_2 = H_1$ and the unique homomorphism from $G_1/G_2$ to $H_1/H_2$ (since these groups are both trivial). (Check that this does indeed produce the subgroup $G_1\times H_1$).
Next, the common example of a subgroup not of this form is in the direct product $G\times G$ where we have the diagonal subgroup given by all elements of the form $(g,g)$. To make this fit in better with the above, assume that $G$ and $H$ are isomorphic and that $\varphi$ is an isomorphism between them (writing it as $G\times G$ then essentially corresponds to having picked an isomorphism). Now, the diagonal above corresponds to the subgroup consisting of all elements of the form $(g,\varphi(g))$, and we see that this subgroup corresponds to picking $G_1 = G$, $H_1 = H$, $G_2 = \{e\}$, $H_2 = \{e\}$ and $\varphi$ as the isomorphism (again, check this).
But we can of course easily generalize the above if the two groups have subgroups $G_1$ and $H_1$ which are isomorphic via some isomorphism $\varphi$, giving us the subgroup consisting of elements of the form $(g,\varphi(g))$, now with $g\in G_1$ and $h\in H_1$. This corresponds to picking $G_1$ and $H_1$ to be those subgroups (hence the choice of notation), and $G_2$ and $H_2$ both to be the trivial subgroup like above (and again the isomorphism should be $\varphi$).
Generalizing further on the above, let us assume that we have two subgroups $G_1$ and $H_1$ and a surjective homomorphism $\varphi':G_1\to H_1$. Now we can again form the subgroup consisting of all elements of the form $(g,\varphi'(g))$ for $g\in G_1$ (we never needed the homomorphism to be bijective above). This corresponds to picking $G_2 = \rm{ker}(\varphi')$, $H_2 = \{e\}$ and $\varphi$ to be the isomorphism $G_1/G_2\to H_1$ induced by $\varphi'$ (check this).
Note that the reason we pick $\varphi'$ to be surjective in the above is that otherwise, we might as well just look at the image of $\varphi'$.
The final step in generalizing these ideas is probably the least intuitive. Namely, we have two subgroups $G_1$ and $H_1$, but we do not necessarily have any homomorphism between them. Instead, we have a homomorphism $\varphi$ from $G_1$ to some quotient $H_1/H_2$ which is surjective (again, the surjectivity is just because otherwise, we would restrict to the image). Let us first assume this map is also injective, to make notations a bit simpler. In this case, we wish to form something like the subgroups from above, but we can no longer just take something like $(g,\varphi(g))$, since $\varphi(g)$ is no longer an element of $H_1$ but an element of $H_1/H_2$. On the other hand, $\varphi(g)$ is a coset of $H_2$ in $H_1$ and is therefore a subset of $H_1$, so for each $g\in G$ we can take all the elements of the form $(g,h)$ where $h$ is in the coset $\varphi(g)$ of $H_2$ in $H_1$. One should again check that this is indeed a subgroup, and that this corresponds to picking $G_1 = \{e\}$ and and the rest are already in the appropriate notation.
To get rid of the requirement of injectivity above, we set $G_2$ to be the kernel of the homomorphism and replace the homomorphism by the induced isomorphism $G_1/G_2\to H_1/H_2$. The pairs we now need are those of the form $(g,h)$ where again $h$ is in the coset $\varphi(g)$ but now we need to interpret $\varphi(g)$ as $\varphi(gG_2)$ (since $\varphi$ need not even be defined on $G_1$). So our elements are those of the form $(g,h)$ where $\varphi(gG_2) = hH_2$. This is fortunately precisely the form given by the characterization, so we now have all the possible subgroups.
Let's now, finally, take a look at finding the number of subgroups of $\mathbb{Z}/p^2\mathbb{Z}\times \mathbb{Z}/p^2\mathbb{Z}$.
So we need to find all possible $5$-tuples as above. Since each of the factors have precisely $3$ subgroups, all isomorphism classes of subgroups and quotients are determined by their order, and the tuples need the two quotients to be isomorphic, we get a total of $14$ types of tuples ($9$ where the order is $1$, $4$ where the order is $p$ and $1$ where the order is $p^2$), and for each we then need to know how many isomorphisms we can pick.
To make the notation a bit easier, denote the group by $G\times H$. Let $G'$ and $H'$ be the proper, non-trivial subgroups of $G$ and $H$ respectively. Denote by $1$ the trivial subgroup of either.
Our tuples then have the forms given below. The number after each tuple is the number of possible isomorphisms $\varphi$ we can pick (this number is the order of the automorphism group of $G_1/G_2$ which is of course also the order of the automorphism group of $H_1/H_2$. In our cases, these automorphism groups are easy to calculate as the possible quotients are all cyclic).
$(G,G,H,H,\varphi)$ $1$
$(G,G,H',H',\varphi)$ $1$
$(G,G,1,1,\varphi)$ $1$
$(G,G',H,H',\varphi)$ $p-1$
$(G,G',H',1,\varphi)$ $p-1$
$(G,1,H,1,\varphi)$ $p^2 - p$
$(G',G',H,H,\varphi)$ $1$
$(G',G',H',H',\varphi)$ $1$
$(G',G',1,1,\varphi)$ $1$
$(G',1,H,H',\varphi)$ $p-1$
$(G',1,H',1,\varphi)$ $p-1$
$(1,1,H,H,\varphi)$ $1$
$(1,1,H',H',\varphi)$ $1$
$(1,1,1,1,\varphi)$ $1$
Now it is just a matter of adding these number together to see that the total number of subgroups is $(p^2 - p) + 4(p-1) + 9 = p^2 + 3p + 5$.