Kernel pairs, coequalizers and epimorphisms Suppose we have a category $C$ having kernel pairs and coequalizers. Suppose we have an epimorphism $f:Y\to X$ in $C$, and consider the Kernel pair $p_1,p_2:Y\times_X Y  \rightrightarrows Y$; then $$X=\operatorname{coeq}(Y\times_X Y  \rightrightarrows Y).$$
Suppose also we have another pair of arrows $h_1,h_2:Z \rightrightarrows Y$.
If $X= \operatorname{coeq}(Z  \rightrightarrows Y)$ (meaning that $X$ verifies the universal property of the coequalizer), then there exists a morphism $h:Z\to Y\times_X Y$ such that $h_i=p_i\circ h$.
On the other hand, given any morphism $h:Z\to Y\times_X Y$, denote $h_i:==p_i\circ h$; one get a natural morphism $ \pi:\operatorname{coeq}(h_1,h_2)\to X$, necessarily an epimorphism.

Question: What property of $h$ is equivalent to  that $\pi$ is an isomorphim?

My guess is that the necessary and sufficient condition on $h$ is to be an epimorphism.
I can show the sufficiency: if $h$ is an epimorphims, then $\pi $ is an isomorphim. To find an inverse $\rho$ of $\pi$, we want a morphism $ \rho:X\to \operatorname{coeq}(h_1,h_2)$ such that $\rho\circ f=:\tau:Y\to \operatorname{coeq}(h_1,h_2)$ is the projection map to the coequalizer (i.e. it verifies the universal property...). By the universal property of $f:Y\to X$ as a coequalizer of the kernel pair, one gets the result if and only if the morphism $\tau$ verifies that $\tau\circ p_1=\tau \circ p_2$. But $$\tau\circ p_1\circ h=\tau \circ h_1=\tau\circ h_2=\tau\circ p_2\circ h$$
and if $h$ is an epimorphism, one deduces that $\tau\circ p_1=\tau \circ p_2$. That the morphisms $\rho$ and $\pi$ are inverse one of the other is deduced from the unicity of the maps from the corresponding universal properties.
 A: I explain why I was wrong, following the indications of Zhen Lin in the comments.
We take any surjective map $f:Y\to X$, construct $Y\times_X Y$ which is formed by the subset of elements $(y_1,y_2)\in Y\times Y$ such that $f(y_1)=f(y_2)$.
We work in the category of sets. Suppose moreover that the map
$h:Z\to Y \times_X Y$ is injective, so we identify $Z$ with a subset of $Y\times_X Y=Y\times Y$ (we can essentially reduce to this case by taking the image of $h$).
Now, the coequalizer $\text{coeq}(h_1,h_2)$ is given by $X/\sim$, where $\sim$ is the equivalence relation generated by $Z$. So, the condition I was asking for is that the minimum equivalence relation generated by $Z$ is $Y\times_X Y$; an of course there are examples when $Z\subsetneq Y\times_X Y$.
A general contraexample: given a $f:Y\to X$ surjective but not bijective, we construct $Z$ such that for any pair $(y_1,y_2)\in Y\times_X Y$, with $y_1\ne y_2$, we take out $(y_2,y_1)$; for example if there is a total order in $Y$, we consider only the pairs $(y_1,y_2)$ such that $y_1<y_2$ (and $f(y_1)=f(y_2)$).
It seems that there is no easy property on $h$ giving the condition I want.
