Terminal object implies projection is an isomorphism
We have $gp : X \times A \to X \times A$ and $pgp = p : X \times A \to X$.
Apply universality of the product diagram once more.
We have $gp : X \times A \to X \times A$ and $pgp = p : X \times A \to X$.
Apply universality of the product diagram once more.