Let $X \xrightarrow{x} Z \xleftarrow{y} Y$ be a cospan of sets, and consider the pullback $X \times_Z Y$.
Given $f\colon Y \to Y'$, I would like to show that $\newcommand{\id}{\operatorname{id}}\id_X \times_Z f$ is an isomorphism if, and only if, $f$ is an isomorphism.
The if-direction is clear, but I'm struggling with $\implies$.
Specifically, I'm struggling with showing that $(\id \times_Z f)^{-1}$ is again of the form $\id \times_Z g$.
So let $\id_X \times_Z f$ be invertible. By the universal property of pullbacks, we have \begin{align} \operatorname{Fun}(X \times_Z Y', X\times_Z Y) \cong \{ (\alpha, \beta) \mid x \circ \alpha = y \circ \beta \} \subset \operatorname{Fun}(X \times_Z Y', X) \times \operatorname{Fun}(X \times_Z Y', Y) \ , \end{align} and given some map $u$ on the LHS, the two maps on the RHS are determined by \begin{align} \alpha = \pi_1 \circ u \quad \text{and} \quad \beta = \pi_2 \circ u \ , \end{align} where $\pi_i$ are the projections. So, for $u = (\id_X \times_Z f)^{-1}$, we are obviously forced to have $\alpha = \pi_1$, but of $\beta$ we only know that its some function $X \times_Z Y' \to Y$ satisfying $\beta \circ \id \times_B f = \pi_2$.
So I don't really see how/where the $X$-dependence of $\beta$ vanishes. Any help would be appreciated.
Edit: Let us also assume that $X \to Z$ is a surjection and that $Z$ is not empty.