Is it true, that every morphism in a product is a retraction?

Almost.

It only works if some arrow $A\to B$ indeed exists.

If we are e.g. working in the category of sets with $B=\varnothing$ and $A\neq\varnothing$ then this is not the case and also $P=A\times B=\varnothing$.

In that case $f:P=\varnothing\to A\neq\varnothing$ has no right-inverse.


That seems ok, as long as there are arrows $A \to B$, because the existence of $h$ will be guaranteed provided that you give morphims $C \to A$ and $C \to B$, in which case $\phi = fh$ and $\psi = gh$ ought to exist.

If you have any arrow $a : A \to B$ then $(id_A,a)$ factors through $P$ via some unique $h$ as you have said.

As drhab has said in his answer, there are rather elementary examples in which this fails already. I know little category theory, but maybe more 'interesting' examples can be fabricated out of well known objects with no arrows between them.