
So I did the math for this and got
\begin{align*} A &= a_1a_2 + b_1c_2\\ B &= a_1b_2 + b_1d_2\\ C &= c_1a_2 + d_1c_2\\ D &= c_1b_2 + d_1d_2. \end{align*}
My book does not talk about how or where $A, B, C,$ and $D$ came from. It just talks about
$$f(x) = \frac{ax+b}{cx+d}.$$
How are these related and how are the values $A, B, C,$ and $D$ determined?
If
$$f(x) = \frac{a_1x+b_1}{c_1x+d_1},\quad g(x) = \frac{a_2x + b_2}{c_2x+d_2},$$
then
$$(f\circ g)(x) = \frac{Ax+B}{Cx+D}$$
where
$$\left[\begin{matrix} A & B\\ C & D\end{matrix}\right] = \left[\begin{matrix} a_1 & b_1\\ c_1 & d_1\end{matrix}\right]\left[\begin{matrix} a_2 & b_2\\ c_2 & d_2\end{matrix}\right]$$
(you should verify this). Using the correspondence the other way (from $2\times 2$ matrices to fractional linear transformations), we have to make sure that at least one of the entries in the second row is non-zero - to ensure this condition is met, let's only consider invertible matrices from this point on (i.e. the general linear group). The association
$$\left[\begin{matrix}a &b\\ c& d\end{matrix}\right] \mapsto \frac{ax+b}{cx+d}$$
is not injective because the matrices $A$ and $kA$ ($k\neq 0$) correspond to the same fractional linear transformation. To remove this ambiguity, we often consider matrices up to scale (the projectivised general linear group).
If you know some complex analysis, there is more to be said. In particular, the relationship between $\operatorname{PGL}(2, \mathbb{C})$, the automorphisms of the Riemann sphere $\hat{\mathbb{C}}$, and the fact that $\hat{\mathbb{C}} \cong \mathbb{CP}^1$.