[proofplan]
We prove exactness at $S^{-1}B$, i.e., $\ker(S^{-1}g) = \operatorname{im}(S^{-1}f)$. The inclusion $\operatorname{im}(S^{-1}f) \subset \ker(S^{-1}g)$ follows from the functoriality of localization: $(S^{-1}g) \circ (S^{-1}f) = S^{-1}(g \circ f) = 0$ since $g \circ f = 0$. For the reverse inclusion, we take an element $\frac{b}{s} \in \ker(S^{-1}g)$, use the definition of equality in the localization to find $u \in S$ with $ub \in \ker g = \operatorname{im} f$, lift $ub$ to an element of $A$, and express $\frac{b}{s}$ as an element of $\operatorname{im}(S^{-1}f)$.
[/proofplan]
[step:Recall the localized maps and prove $\operatorname{im}(S^{-1}f) \subset \ker(S^{-1}g)$]
The localized maps are defined on fractions by
\begin{align*}
S^{-1}f: S^{-1}A &\to S^{-1}B, \quad \frac{a}{s} \mapsto \frac{f(a)}{s}, \\
S^{-1}g: S^{-1}B &\to S^{-1}C, \quad \frac{b}{s} \mapsto \frac{g(b)}{s}.
\end{align*}
These are well-defined $S^{-1}R$-module homomorphisms. The composition satisfies
\begin{align*}
(S^{-1}g) \circ (S^{-1}f)\!\left(\frac{a}{s}\right) = S^{-1}g\!\left(\frac{f(a)}{s}\right) = \frac{g(f(a))}{s} = \frac{0}{s} = 0,
\end{align*}
where $g(f(a)) = 0$ because $\operatorname{im} f \subset \ker g$ (exactness of the original sequence at $B$). Since $S^{-1}(g \circ f) = 0$, every element of $\operatorname{im}(S^{-1}f)$ lies in $\ker(S^{-1}g)$.
[/step]
[step:Prove $\ker(S^{-1}g) \subset \operatorname{im}(S^{-1}f)$ by lifting through the localization]
Let $\frac{b}{s} \in \ker(S^{-1}g)$, so $\frac{g(b)}{s} = \frac{0}{1}$ in $S^{-1}C$. By the definition of equality in the localization $S^{-1}C$, there exists $u \in S$ such that
\begin{align*}
u \cdot g(b) = 0 \quad \text{in } C.
\end{align*}
Since $g$ is an $R$-module homomorphism, $g(ub) = ug(b) = 0$, so $ub \in \ker g$. By the exactness hypothesis $\ker g = \operatorname{im} f$, there exists $a \in A$ with $f(a) = ub$. We compute:
\begin{align*}
S^{-1}f\!\left(\frac{a}{us}\right) = \frac{f(a)}{us} = \frac{ub}{us} = \frac{b}{s},
\end{align*}
where the last equality holds because $u \cdot 1 \cdot (ub) - u \cdot u \cdot b = 0$ (taking the witnessing element to be $1 \in S$, or directly: $\frac{ub}{us} = \frac{b}{s}$ since $1 \cdot (s \cdot ub - us \cdot b) = 0$). Therefore $\frac{b}{s} \in \operatorname{im}(S^{-1}f)$.
[guided]
Let $\frac{b}{s} \in \ker(S^{-1}g)$. We want to express $\frac{b}{s}$ as $S^{-1}f(\frac{a'}{s'})$ for some $a' \in A$ and $s' \in S$. The condition $S^{-1}g(\frac{b}{s}) = 0$ means $\frac{g(b)}{s} = \frac{0}{1}$ in $S^{-1}C$.
By the equivalence relation defining $S^{-1}C$, this means there exists $u \in S$ with $u(1 \cdot g(b) - s \cdot 0) = ug(b) = 0$ in $C$. The $R$-linearity of $g$ gives $g(ub) = ug(b) = 0$, so $ub \in \ker g$.
Now we use the exactness of the original sequence: $\ker g = \operatorname{im} f$. Since $ub \in \ker g$, there exists $a \in A$ with $f(a) = ub$. We now construct the preimage of $\frac{b}{s}$ under $S^{-1}f$. Consider the element $\frac{a}{us} \in S^{-1}A$ (note $us \in S$ since $S$ is multiplicative). Then:
\begin{align*}
S^{-1}f\!\left(\frac{a}{us}\right) = \frac{f(a)}{us} = \frac{ub}{us}.
\end{align*}
We claim $\frac{ub}{us} = \frac{b}{s}$ in $S^{-1}B$. Indeed, $1 \cdot (s \cdot ub - us \cdot b) = sub - usb = 0$, so the fractions are equal. Therefore $\frac{b}{s} = S^{-1}f(\frac{a}{us}) \in \operatorname{im}(S^{-1}f)$.
This completes the proof that $\ker(S^{-1}g) \subset \operatorname{im}(S^{-1}f)$, establishing exactness at $S^{-1}B$.
[/guided]
[/step]
[step:Conclude exactness and deduce flatness]
Combining the two inclusions, $\operatorname{im}(S^{-1}f) = \ker(S^{-1}g)$, so the localized sequence is exact at $S^{-1}B$.
For the equivalence with flatness: the functor $S^{-1}(\cdot)$ is naturally isomorphic to $S^{-1}R \otimes_R (\cdot)$ via the canonical isomorphism $S^{-1}M \cong S^{-1}R \otimes_R M$ for any $R$-module $M$. Since exactness of $S^{-1}(\cdot)$ applied to any exact sequence $A \to B \to C$ yields an exact sequence $S^{-1}A \to S^{-1}B \to S^{-1}C$, the functor $S^{-1}R \otimes_R (\cdot)$ is exact. By definition, this means $S^{-1}R$ is a flat $R$-module.
[/step]