\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{nicematrix}
\title{Matrices}
\author{Mavaddat Javid}
\date{December 2022}
\begin{document}
\maketitle
\section{Labelled}
\NiceMatrixOptions{xdots/shorten=0.5em}
\begin{equation}
\setcounter{MaxMatrixCols}{12}
\begin{bNiceMatrix}[first-row,first-col]
& \textcolor{red}{1} & \textcolor{red}{2} & \textcolor{red}{\cdots} & \textcolor{red}{n} \\
\textcolor{green}{1} & a_{\textcolor{green}{1}\textcolor{red}{1}} & a_{\textcolor{green}{1}\textcolor{red}{2}} & \ldots & a_{\textcolor{green}{1}\textcolor{red}{n}} \\
\textcolor{green}{2} & a_{\textcolor{green}{2}\textcolor{red}{1}} & a_{\textcolor{green}{2}\textcolor{red}{2}} & \ldots & a_{\textcolor{green}{2}\textcolor{red}{n}} \\
\textcolor{green}{3} & a_{\textcolor{green}{3}\textcolor{red}{1}} & a_{\textcolor{green}{3}\textcolor{red}{2}} & \ldots & a_{\textcolor{green}{3}\textcolor{red}{n}} \\
\textcolor{green}{\vdots} & \vdots & \vdots & \vdots & \vdots \\
\textcolor{green}{m} & a_{\textcolor{green}{m}\textcolor{red}{1}} & a_{\textcolor{green}{m}\textcolor{red}{2}} & \ldots & a_{\textcolor{green}{m}\textcolor{red}{n}} \\
\end{bNiceMatrix}
\end{equation}
\end{document}