You can put everything you like into the equation environment. Like this, it will behave like an equation which seems to be what you want.
% arara: pdflatex
\documentclass{article}
\usepackage{tikz-cd}
\usepackage{blindtext}
\begin{document}
\setcounter{page}{15}
\noindent
into a commutative diagramm
\begin{equation}
\begin{tikzcd}
B\times_A C \arrow{r}{\pi_2}\arrow{d}[swap]{\pi_1} & C\arrow{d}{g} \\
B \arrow{r}[swap]{f} & A;
\end{tikzcd}
\end{equation}
\blindtext
In a general category $C$, one says that a commutative square
\begin{equation}
\begin{tikzcd}
P \arrow{r}{q}\arrow{d}[swap]{p} & C\arrow{d}{g} \\
B \arrow{r}[swap]{f} & A
\end{tikzcd}
\end{equation}
\blindtext
\end{document}

If you which to have the last diagram as well:
\begin{equation*}
\begin{tikzcd}
X\arrow{drr}{\gamma}\arrow[dashed]{dr}[near end]{!\delta}\arrow{ddr}[swap]{\beta} & & \\[1ex]
& P \arrow{r}{q}\arrow{d}[swap]{p} & C\arrow{d}{g} \\
& B \arrow{r}[swap]{f} & A
\end{tikzcd}
\end{equation*}
equation... – Artem Mavrin Sep 11 '15 at 10:19\usepackage[leqno]{amsmath}– LaRiFaRi Oct 10 '22 at 07:11