The problem arises as \captionof is not overlay-aware, thus a possible solution is to pack within an \only both \includegraphics and \captionof.
An example:
\documentclass[xcolor=x11names,compress]{beamer}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{caption}
\captionsetup{font=scriptsize,labelformat=empty}
\usepackage{mwe} % for dummy images
\begin{document}
\begin{frame}
\centering
\only<1>{
\includegraphics[width=10cm]{example-image-a}%
\captionof{figure}{caption of 1st pic}
}
\includegraphics<2>[width=10cm, height=7cm]{example-image-b}%
\end{frame}
\end{document}
The result:

However, as you can see, a bad jumping effect comes due to the different height of image+caption with respect to image only. Thus to overcome the issue, one could proceed as follows:
\documentclass[xcolor=x11names,compress]{beamer}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{caption}
\captionsetup{font=scriptsize,labelformat=empty}
\usepackage{mwe} % for dummy images
\begin{document}
\begin{frame}
\begin{overlayarea}{\textwidth}{0.875\textheight}
\centering
\only<1>{
\includegraphics[width=10cm]{example-image-a}%
\captionof{figure}{caption of 1st pic}
}
\includegraphics<2>[width=10cm, height=7cm]{example-image-b}%
\end{overlayarea}
\end{frame}
\end{document}
The result:

For more insights see Get a includegraphic to stick in the same place for several beamer slides.