If I have two group, $A,B$, I want to prove that $A\times B\cong B\times A$. So my guess is to define a mapping $$\varphi:A\times B\rightarrow B\times A$$ $$\varphi((a,b))=(b,a)$$.
I must first show that $\varphi$ is well defined, which is pretty clear I think. If we have that $\varphi((a,b))=(b,a)$ and $\varphi((a,b))=(b',a')$, we must have that $b=b'$ and $a=a'$ and so $\varphi$ is well defined.
It is a homomorphism since for elements $(a_1,b_1),(a_2,b_2)\in A\times B$
$$\begin{align} \varphi((a_1,b_1)(a_2,b_2)) &=&\varphi((a_1a_2,b_1b_2)) \\ &=& (b_1b_2,a_1a_2) \\ &=& (b_1,a_1)(b_2,a_2) \\ &=& \varphi((a_1,b_1))\varphi((a_2,b_2)) \end{align}$$
And so we know $\varphi$ is a homomorphism.
Now, surjection is easy since clearly for all $b\in B, a\in A$ and $(b,a)\in B\times A$, we will always have an element in $A\times B$ where $\varphi((a,b))=(b,a)$ since we are just reversing the order of the direct product.
Finally, it is injective since if we know $\varphi((a_1,b_1))=\varphi((a_2,b_2))$, then we have that $(b_1,a_1)=(b_2,a_2)$ which means $a_1=a_2$ and $b_1=b_2$.
Since now $\varphi$ is both injective and surjective, it is bijective, and is also a homomorphism, then we have that $A\times B\cong B\times A$.
Is this a corrrect proof? I was curious of the well defined portion as well defined always gives me issues.