Let $A,B$ be sets, and let $\require{AMScd}$ \begin{CD} A @<<< R\\ & @VV V\\ && B \end{CD} be a span. By the universal property for products, we have a unique map $p: R \implies A \times B.$
We make a matrix of natural numbers out of this data as follows. The set of rows is $A$, the set of columns is $B$. For $a \in A, b \in B$, the $(a, b)$ entry is the cardinality of its preimage, $|p^{-1}(ab)|$, i.e., the number of elements in $R$ that are sent by $p$ to $(a, b)$.
Let $A = \{1, 2\}, B = \{1, 2, 3\}$ and consider the span
$\require{AMScd}$ \begin{CD} A @<f<< R\\ & @VV g V\\ && B \end{CD}
given by the table
\begin{array}{|c|c c|} \hline & R \\ \hline ID& f: A & g:B \\ \hline 1 & 1& 2&\\ \hline 2 & 1& 2&\\ \hline 3 & 1& 3&\\ \hline 4 & 2& 1&\\ \hline 5 & 2& 2&\\ \hline 6 & 2& 3&\\ \hline 7 & 2& 3&\\ \hline 8 & 2& 3&\\ \hline \end{array}
Then the matrix corresponding to this span is
$$ \begin{pmatrix} 0 & 2 & 1 \\ 1 & 1 & 3 \\ \end{pmatrix} $$
I am having difficuty seeing how they obtained the matrix. Can somebody, please, explain what they did to obtain the entries of the matrix. I've been stairing at it for a while now and still can't make sense of it.