As David has said, using a tabular environment can put contents at the center.
Since you are already using tabularx, I assume you want the contents to fill the column width, so it should be based on the X column type, but with a little modification to make it centered (as is discussed here)
\newcolumntype{Y}{>{\centering\arraybackslash}X} % centered X
Therefore, it is
\documentclass{article}
\usepackage{tabularx}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
\begin{table}
\caption{caption}
\begin{tabularx}{\columnwidth}{|Y||Y|Y|Y|Y|}
\hline
& 1 & 2 & 3 & 4 \
\hline
A & B & C & D & E \
\hline
\end{tabularx}
\end{table}
\end{document}

By the way, when asking a question, it would be better if you provide a full minimum working example (MWE) from \documentclass to \end{document}.
tabularnottabularx– David Carlisle Jan 11 '23 at 14:24