[proofplan]
The quotient map coequalizes $f$ and $g$ because the congruence $\sim$ was chosen to identify each pair $f(a)$ and $g(a)$. To prove the universal property, take any homomorphism $h: B \to C$ with $h \circ f = h \circ g$ and show that its kernel congruence contains the generating pairs, hence contains all of $\sim$. This makes $h$ constant on $\sim$-equivalence classes, so it descends to a unique homomorphism $\bar h: B/{\sim} \to C$ satisfying $\bar h \circ q = h$.
[/proofplan]
[step:Verify that the quotient map coequalizes the two homomorphisms]
Let
\begin{align*}
q: B &\to B/{\sim} \\
b &\mapsto [b]_{\sim}
\end{align*}
be the canonical quotient homomorphism. For every $a \in A$, the defining property of $\sim$ gives $f(a) \sim g(a)$, and therefore
\begin{align*}
q(f(a)) = [f(a)]_{\sim} = [g(a)]_{\sim} = q(g(a)).
\end{align*}
Hence the two homomorphisms
\begin{align*}
q \circ f, q \circ g: A \to B/{\sim}
\end{align*}
agree on every element of $A$, so
\begin{align*}
q \circ f = q \circ g.
\end{align*}
[/step]
[step:Show that every coequalizing homomorphism is constant on $\sim$-classes]
Let $C$ be an object of $\mathcal C$, and let
\begin{align*}
h: B \to C
\end{align*}
be a homomorphism satisfying
\begin{align*}
h \circ f = h \circ g.
\end{align*}
Define the kernel relation of $h$ by
\begin{align*}
\ker(h) := \{(b_1,b_2) \in B \times B : h(b_1) = h(b_2)\}.
\end{align*}
This relation is a congruence on $B$: it is an [equivalence relation](/page/Equivalence%20Relation) because equality in $C$ is an equivalence relation, and it is compatible with all basic operations because $h$ is a homomorphism. Indeed, if $\omega$ is an $n$-ary operation symbol and $(b_i,c_i) \in \ker(h)$ for $1 \le i \le n$, then
\begin{align*}
h(\omega_B(b_1,\dots,b_n))
&= \omega_C(h(b_1),\dots,h(b_n)) \\
&= \omega_C(h(c_1),\dots,h(c_n)) \\
&= h(\omega_B(c_1,\dots,c_n)),
\end{align*}
so
\begin{align*}
(\omega_B(b_1,\dots,b_n),\omega_B(c_1,\dots,c_n)) \in \ker(h).
\end{align*}
For each $a \in A$, the equality $h \circ f = h \circ g$ gives
\begin{align*}
h(f(a)) = h(g(a)),
\end{align*}
so $(f(a),g(a)) \in \ker(h)$. Thus $\ker(h)$ is a congruence on $B$ containing every generating pair $(f(a),g(a))$. Since $\sim$ is the smallest such congruence, we have
\begin{align*}
\sim \ \subseteq \ker(h).
\end{align*}
Consequently, whenever $b_1,b_2 \in B$ satisfy $b_1 \sim b_2$, we have $h(b_1)=h(b_2)$.
[/step]
[step:Construct the induced homomorphism on the quotient]
Define
\begin{align*}
\bar h: B/{\sim} &\to C \\
[b]_{\sim} &\mapsto h(b).
\end{align*}
This map is well-defined: if $[b_1]_{\sim} = [b_2]_{\sim}$, then $b_1 \sim b_2$, and the previous step gives $h(b_1)=h(b_2)$.
The map $\bar h$ is a homomorphism. Let $\omega$ be an $n$-ary operation symbol and let $[b_1]_{\sim},\dots,[b_n]_{\sim} \in B/{\sim}$. Since the quotient algebra operations are defined by
\begin{align*}
\omega_{B/{\sim}}([b_1]_{\sim},\dots,[b_n]_{\sim})
=
[\omega_B(b_1,\dots,b_n)]_{\sim},
\end{align*}
we obtain
\begin{align*}
\bar h(\omega_{B/{\sim}}([b_1]_{\sim},\dots,[b_n]_{\sim}))
&= \bar h([\omega_B(b_1,\dots,b_n)]_{\sim}) \\
&= h(\omega_B(b_1,\dots,b_n)) \\
&= \omega_C(h(b_1),\dots,h(b_n)) \\
&= \omega_C(\bar h([b_1]_{\sim}),\dots,\bar h([b_n]_{\sim})).
\end{align*}
Since the morphisms of $\mathcal C$ are exactly the homomorphisms between its objects, this homomorphism $\bar h$ is a morphism in $\mathcal C$.
For every $b \in B$,
\begin{align*}
(\bar h \circ q)(b)
=
\bar h([b]_{\sim})
=
h(b),
\end{align*}
so
\begin{align*}
\bar h \circ q = h.
\end{align*}
[/step]
[step:Prove uniqueness of the induced homomorphism]
Let
\begin{align*}
k: B/{\sim} \to C
\end{align*}
be a homomorphism satisfying
\begin{align*}
k \circ q = h.
\end{align*}
For every equivalence class $[b]_{\sim} \in B/{\sim}$, we have
\begin{align*}
k([b]_{\sim})
=
k(q(b))
=
h(b)
=
\bar h([b]_{\sim}).
\end{align*}
Hence $k$ and $\bar h$ agree on every element of $B/{\sim}$, so $k=\bar h$.
We have shown that $q \circ f = q \circ g$, and that every morphism $h: B \to C$ in $\mathcal C$ satisfying $h \circ f = h \circ g$ factors uniquely through the morphism $q$ by a morphism $\bar h: B/{\sim} \to C$ in $\mathcal C$. Therefore $q: B \to B/{\sim}$ is a coequalizer of $f$ and $g$ in $\mathcal C$.
[/step]