how to insert a fixed number of figures per row/column?

There are several possibilities here.

Case A: ten subfigures

Three options: the first one, using the subfig package; the second one, using the subcaption package; the third one, using the floatrow package.

Using subfig:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}

\captionsetup[subfigure]{justification=raggedright}

\begin{document}

\begin{figure}
\centering
\subfloat[first subfigure]{\label{sfig:a}\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subfloat[second subfigure]{\label{sfig:b}\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subfloat[third subfigure]{\label{sfig:c}\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subfloat[fourth subfigure]{\label{sfig:d}\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subfloat[fifth subfigure]{\label{sfig:e}\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\\
\subfloat[sixth subfigure]{\label{sfig:f}\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subfloat[seventh subfigure]{\label{sfig:g}\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subfloat[eighth subfigure]{\label{sfig:h}\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subfloat[ninth subfigure]{\label{sfig:i}\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subfloat[tenth subfigure]{\label{sfig:j}\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\\
\caption{A figure with ten subfigures}
\label{fig:test}
\end{figure}

\end{document}

enter image description here

Using subcaption:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}

\captionsetup[subfigure]{justification=raggedright}

\begin{document}

\begin{figure}
\centering
\subcaptionbox{first subfigure\label{sfig:a}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subcaptionbox{second subfigure\label{sfig:b}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subcaptionbox{third subfigure\label{sfig:c}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subcaptionbox{fourth subfigure\label{sfig:d}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subcaptionbox{fifth subfigure\label{sfig:e}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\\
\subcaptionbox{sixth subfigure\label{sfig:f}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subcaptionbox{seventh subfigure\label{sfig:g}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subcaptionbox{eighth subfigure\label{sfig:h}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subcaptionbox{ninth subfigure\label{sfig:i}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subcaptionbox{tenth subfigure\label{sfig:j}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\\
\caption{A figure with ten subfigures}
\label{fig:test}
\end{figure}

\end{document}

enter image description here

Using floatrow:

\documentclass{article}
\usepackage{subcaption}
\usepackage{floatrow}
\usepackage{graphicx}

\renewcommand\subfloatrowsep{\hskip7pt} 

\begin{document}

\begin{figure}
\captionsetup{justification=raggedright}
\ffigbox[\textwidth]{%
\begin{subfloatrow}[5]
\ffigbox[\FBwidth]{\caption{first subfigure}\label{sfig:a}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{second subfigure}\label{sfig:b}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{third subfigure}\label{sfig:c}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{fourth subfigure}\label{sfig:d}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{fifth subfigure}\label{sfig:e}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\end{subfloatrow}
\begin{subfloatrow}[5]
\ffigbox[\FBwidth]{\caption{sixth subfigure}\label{sfig:f}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{seventh subfigure}\label{sfig:g}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{eighth subfigure}\label{sfig:h}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{ninth subfigure}\label{sfig:i}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{tenth subfigure}\label{sfig:j}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\end{subfloatrow}
}{\caption{A figure with ten subfigures}\label{fig:test}}
\end{figure}

\end{document}

enter image description here

Case B: ten independent figures

If we are talking about an array of ten independent figures, ten minipages can be used.

If the whole construct should be allowed to float, the minipages can go inside a figure environment:

\documentclass{article}
\usepackage{caption}
\usepackage{graphicx}

\begin{document}

\begin{figure}
\captionsetup{justification=raggedright}
\centering
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{first figure}
\label{fig:a}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{second figure}
\label{fig:b}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{third figure}
\label{fig:c}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{fourth figure}
\label{fig:d}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{fifth figure}
\label{fig:e}
\end{minipage}\\
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{sixth figure}
\label{fig:f}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{seventh figure}
\label{fig:g}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{eighth figure}
\label{fig:h}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{ninth figure}
\label{fig:i}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{tenth figure}
\label{fig:j}
\end{minipage}
\end{figure}

\end{document}

enter image description here

If the whole construct shouldn't be allowed to float, the ten minipages can go inside a minipage environment (or a center environment); in this situation, captions can be provided using \captionof (from the caption or capt-of packages):

\documentclass{article}
\usepackage{caption}
\usepackage{graphicx}

\begin{document}

\noindent\begin{minipage}{\textwidth}
\captionsetup{justification=raggedright}
\centering
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{first figure}
\label{fig:a}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{second figure}
\label{fig:b}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{third figure}
\label{fig:c}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{fourth figure}
\label{fig:d}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{fifth figure}
\label{fig:e}
\end{minipage}\\
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{sixth figure}
\label{fig:f}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{seventh figure}
\label{fig:g}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{eighth figure}
\label{fig:h}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{ninth figure}
\label{fig:i}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{tenth figure}
\label{fig:j}
\end{minipage}
\end{minipage}

\end{document}