Let $A$ be a commutative ring and $B,C$ be two commutative $A$-algebras. Consider the pushout square of ring homomorphism $\require{AMScd}$ \begin{CD} A@>>>B\\ @VVV@VVV\\ C@>>>B\otimes_AC \end{CD} and the corresponding commutative square of spectrum $\DeclareMathOperator\Spec{Spec}$ \begin{CD} \Spec(B\otimes_AC)@>>>\Spec(B)\\ @VVV@VVV\\ \Spec(C)@>>>\Spec(A) \end{CD} If $C=A/\mathfrak a$ for some ideal $\mathfrak a$ of $A$ or $C=S^{-1}A$ for some mutliplicative system $S$ of $A$, then the square of spectrums is a pullback square.
If $A\to C$ is an epimorphism of commutative rings then the bottom square is always a pullback?
Here there is a similar question regarding the spectrum square in the category of sets.
$\DeclareMathOperator{\Spec}{Spec}$This is true for all $A$-algebras $B$ and $C$. You can find a proof in any textbook on scheme theory that covers fiber products (e.g. Hartshorne's Algebraic Geometry, Theorem 3.3 in Chapter II). The argument is more or less as follows: It suffices to check that $\Spec(B\otimes_AC)$ satisfies the universal property of the fiber product (i. e. pullback) $\Spec B\times_{\Spec A}\Spec C$. Recall that for any scheme $Z$ and any ring $R$ we have a canonical isomorphism $$ \hom(Z, \Spec R) \cong \hom(R, \Gamma(Z, \mathcal O_Z)). $$ Using this and the universal property of $B\otimes_AC$ as a pushout, we have a chain of natural isomorphisms \begin{align*} \hom(Z, \Spec(B\otimes_AC)) &= \hom(B\otimes_AC, \Gamma(Z,\mathcal O_Z))\\ &= \hom(B, \Gamma(Z,\mathcal O_Z)) \times_{\hom(A, \Gamma(Z, \mathcal O_Z))} \hom(C, \Gamma(Z, \mathcal O_Z))\\ &= \hom(Z, \Spec B)\times_{\hom(Z, \Spec A)} \hom(Z, \Spec C) \end{align*} for any scheme $Z$. This shows that $\Spec (B\otimes_AC)$ satisfies the universal property of a fiber product.