Identity for categorical product is terminal?
The answer is no. Consider for instance $\mathbf{C}$ the full subcategory of $\mathbf{Ab}$ (the category of abelian groups) consisting of only the single object $\mathbb{Z}^\mathbb{N}$. Now, $\mathbb{Z}^\mathbb{N}$ is isomorphic to $\mathbb{Z}^\mathbb{N}\times\mathbb{Z}^\mathbb{N}$ in $\mathbf{Ab}$, and we can exploit this fact to show that $\mathbf{C}$ is closed under binary products. To see this, define projection maps $\pi_1,\pi_2:\mathbb{Z}^\mathbb{N}\to\mathbb{Z}^\mathbb{N}$ by \begin{align} \pi_1(x_0,x_1,\dots)&= (x_0,x_2,x_4,\dots)\\ \pi_2(x_0,x_1,\dots)&= (x_1,x_3,x_5,\dots). \end{align} I'll leave it to you to show that this indeed induces a product structure on $\mathbb{Z}^\mathbb{N}$. In particular, your desired condition holds for $B=\mathbb{Z}^\mathbb{N}$ in $\mathbf{C}$, but $\mathbb{Z}^\mathbb{N}$ is certainly not a terminal object in $\mathbf{C}$; it has many non-identity endomorphisms.
If we strengthen the condition, we can get an affirmative answer.
Namely, first assume that specifically the second projection $\pi_2:B\times A\to A$ is invertible for all objects $A$ (implying that the isomorphism is natural in $A$).
Then we can conclude that $B$ is a terminal object:
For any object $A$ we have an arrow $A\overset{\pi_2^{-1}}\to B\times A\overset{\pi_1}\to B$, and this is unique, since for any $f:A\to B$, the arrow $(f,1_A):A\to B\times A$ is a right inverse of $\pi_2$, as $\pi_2\circ(f,1_A)=1_A$, hence it is its inverse now, and thus $$f=\pi_1\circ (f,1_A)=\pi_1\circ\pi_2^{-1}\,.$$
Secondly, if we only have a natural isomorphism $\tau_A:A\to B\times A$, the conclusion still holds:
Let $\alpha_A:=\pi_2\circ\tau_A:A\to A$, this is still natural in $A$, and consider $u:=\tau_A^{-1}\circ (f,1_A):A\to A$ with an arbitrary $f:A\to B\ $ (say, $f=\pi_1\circ\tau_A$), then by naturality of $\alpha:{\rm id}_{\bf C}\to{\rm id}_{\bf C}$, we obtain $$\alpha_A\circ u = u\circ\alpha_A$$ where we have $\alpha_A\circ u=\pi_2\circ (f,1_A)=1_A$, so $\alpha_A$ and hence also $\pi_2$ is invertible, and $(f,1_A)=\pi_2^{-1}$ with every $f$, showing its uniqueness as above.