A product $A\times B$ is a triple $(A,B,A\times B)$ equipped with maps $\pi_A\colon A\times B\to A$, and $\pi_B\colon A\times B\to B$ such that given any pair of maps $\psi_A\colon X\to A$ and $\psi_B\colon X\to B$, there is a unique map $\psi\colon X\to A\times B$, such that $\psi_A=\pi_a\circ \psi$ and $\psi_B=\pi_B\circ \psi$. Hence for $X = A\times B$, (and some given maps) if the identity map $A\times B\to A\times B$ fulfills this role, then any other map also fulfilling it equals the identity map.
I.e. to prove that $fg$ is the identity, check that it does satisfy some property that is only satisfied by one unique map, and then check that the identity also satisfies it. Examples are given in the algebra notes 843-4-5 on my website.
Specifically, look on pages 8-9 of the notes 845-3, for exactly this proof of uniqueness of products.