Most often, the $S$-matrix is defined as an operator between asymptotic initial and final Hilbert spaces for a time-dependent scattering process, i.e. between $t\to-\infty$ and $t\to\infty$. There unitarity encodes conservation of probabilities over time. On the other hand, the book that OP mentions, Ref. 1, talks about a time-independent scattering process. For a discussion of the connection between time-dependent and time-independent scattering, see this Phys.SE question.
In this answer we will only consider time-independent scattering. Ref. 1 defines for a 1D system (divided into three regions $I$, $II$, and $III$, with a localized potential $V(x)$ in the middle region $II$), a $2\times 2$ scattering matrix $S(k)$ as a matrix that tells how two asymptotic incoming (left- and right-moving) waves (of wave number $\mp k$ with $k>0$) are related to two asymptotic outgoing (left- and right-moving) waves. In formulas,
$$\begin{align}\left. \psi(x) \right|_{I}~=~& \underbrace{A(k)e^{ikx}}_{\text{incoming right-mover}} + \underbrace{B(k)e^{-ikx}}_{\text{outgoing left-mover}}, \tag{1} \cr
\left. \psi(x)\right|_{III}~=~& \underbrace{F(k)e^{ikx}}_{\text{outgoing right-mover}} + \underbrace{G(k)e^{-ikx}}_{\text{incoming left-mover}}, \tag{2}\cr
k~>~&0,\end{align}
$$
$$ \begin{pmatrix} B(k) \\ F(k) \end{pmatrix}~=~ S(k) \begin{pmatrix} A(k) \\ G(k) \end{pmatrix}.\tag{3}$$
To show that a finite-dimensional matrix $S(k)$ is unitary, it is enough to show that $S(k)$ is an isometry,
$$\begin{align} S(k)^{\dagger}S(k)~\stackrel{?}{=}~&{\bf 1}_{2\times 2}
\cr\quad\Updownarrow~&\quad\cr
|A(k)|^2+ |G(k)|^2~\stackrel{?}{=}~&|B(k)|^2+ |F(k)|^2,\end{align}\tag{4}$$
or equivalently,
$$ |A(k)|^2-|B(k)|^2 ~\stackrel{?}{=}~|F(k)|^2-|G(k)|^2.\tag{5} $$
Equation (5) can be justified by the following comments and reasoning.
$\psi(x)$ is a solution to the time-independent Schrödinger equation (TISE)
$$\begin{align}
\hat{H} \psi(x) ~=~& E \psi(x), \cr
\hat{H}~:=~&\frac{\hat{p}^2}{2m}+V(x),\cr
\hat{p}~:=~&\frac{\hbar}{i}\frac{\partial}{\partial x},\end{align}\tag{6}$$
for positive energy $E>0$.
The solution space for the Schrödinger eq. $(6)$, which is a second-order linear ODE, is a two-dimensional vectors space.
It follows from eq. $(6)$ that the wave numbers $\pm k$,
$$k ~:=~\frac{\sqrt{2mE}}{\hbar} ~\geq~ 0,\tag{7} $$
must be the same in the two asymptotic regions $I$ and $III$. This will imply that the $M$-matrix (to be defined below) and the $S$-matrix are diagonal in $k$-space.
Moreover, it follows that there exists a bijective linear map
$$ \begin{pmatrix} A(k) \\ B(k) \end{pmatrix} ~\mapsto~ \begin{pmatrix} F(k) \\ G(k) \end{pmatrix}.\tag{8} $$
In Ref. 2, the transfer matrix $M(k)$ is defined as the corresponding matrix
$$ \begin{pmatrix} F(k) \\ G(k) \end{pmatrix}~=~ M(k) \begin{pmatrix} A(k) \\ B(k) \end{pmatrix}.\tag9$$
The $S$-matrix $(3)$ is a rearrangement of eq. $(9)$.
One may use the Schrödinger eq. $(6)$ (and the reality of $E$ and $V(x)$) to show that the Wronskian $$ W(\psi,\psi^{\ast})(x)~=~\psi(x)\psi^{\prime}(x)^{\ast}-\psi^{\prime}(x)\psi(x)^{\ast},\tag{10}$$
or equivalently the probability current
$$ J(x)~=~\frac{i\hbar}{2m} W(\psi,\psi^{\ast})(x),\tag{11}$$
does not depend on the position $x$,
$$\begin{align} \frac{\mathrm dW(\psi,\psi^*)(x)}{\mathrm dx}
~=~&\psi(x)\psi^{\prime\prime}(x)^{\ast}-\psi^{\prime\prime}(x)\psi(x)^{\ast}\cr
~\stackrel{(6)}{=}~&0.\end{align}\tag{12}$$
Unitarity (5) is equivalent to the statement that
$$\left. W(\psi,\psi^*)\right|_{I}~=~\left. W(\psi,\psi^*) \right|_{III}.\tag{13}$$
Ref. 3 mentions that eq. $(12)$ encodes conservation of energy in the scattering.
References:
D.J. Griffiths, Introduction to Quantum Mechanics; Section 2.7 in 1st
edition from 1994 and Problem 2.52 in 2nd edition from 1999.
D.J. Griffiths, Introduction to Quantum Mechanics; Problem 2.49 in 1st edition from 1994 and Problem 2.53 in 2nd edition from 1999.
P.G. Drazin & R.S. Johnson, Solitons: An Introduction, 2nd edition, 1989; Section 3.2.