By default (without hyperref), there's only one thing to keep track of when it comes to setting \labels - a number. And, since number changes (via \stepcounter, \refstepcounter, \addtocounter and \setcounter) are global, one would think that placing a \label shortly after a counter will capture the appropriate number for \referencing. However, it's not the actual number that is capture, but it's representation (which could be different; for example \thesection is often <chapter>.<section> or technically \thechapter.\arabic{section}). This representation is captured in a macro \@currentlabel and is stored locally. You can see this by means of the following MWE:

\documentclass{article}
\begin{document}
\makeatletter% Just for this example
\setcounter{figure}{5}% Just for this example
Figure counter and current label (1): \thefigure~/~@currentlabel
\begin{figure}[h]
Figure counter and current label (2): \thefigure~/~@currentlabel
\caption{A figure}
Figure counter and current label (3): \thefigure~/~@currentlabel
\end{figure}
Figure counter and current label (4): \thefigure~/~@currentlabel
\end{document}
Note how the figure counter's value changes from (1) through (4), even though it's set in a group at (2) and (3) (the figure environment). However, the only time you capture the correct number for a \label is after \caption, but before the local group is terminated (here the figure environment, again).
This confirms the "requirement" to have a \label close to where the appropriate counter is stepped, especially when working with groups (like floats or lists).
With hyperref, however, there's an additional component that is stored with every \label - the hyperlink anchor (technically \@currentHref). This anchor acts in the same way as \@currentlabel. That is, it's is a macro that is updated with every appropriate \refstepcounter. One change though is that hyperref updates \@currentHref globally; it therefore survives the scope of the current group. An expansion of the above MWE shows this:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\makeatletter% Just for this example
\setcounter{figure}{5}% Just for this example
Figure counter, current label and anchor name (1): \thefigure~/~@currentlabel~/~@currentHref
\begin{figure}[h]
Figure counter, current label and anchor name (2): \thefigure~/~@currentlabel~/~@currentHref
\caption{A figure}
Figure counter, current label and anchor name (3): \thefigure~/~@currentlabel~/~@currentHref
\end{figure}
Figure counter, current label and anchor name (4): \thefigure~/~@currentlabel~/~@currentHref
\end{document}
Note how at position (3) both \@currentlabel and \@currentHref have correctly-updated values pointing to the figure. However, immediately outside that group, \@currentlabel is lost, while \@currentHref persists (due to it's global nature).
To get around all this, it's best to place your \label as close to the appropriate counter change as possible, especially when using hyperref in order to avoid confusion with anchors pointing to incorrect content. Your example, with a \label within the \caption - somewhere before the internal enumerate* - is updated below:

\documentclass{article}
\usepackage[inline]{enumitem}
\setlist[enumerate,1]{label=\textit{(\alph*)}}
% https://tex.stackexchange.com/q/1863/5764
\usepackage{hyperref}% Load hyperref last
\begin{document}
\begin{figure}
\caption[]{\label{fig:foo1}figure-caption \begin{enumerate}\item 1\item2\end{enumerate}}
\label{fig:foo2}
\end{figure}
\autoref{fig:foo1}
\autoref{fig:foo2}
\end{document}
fig:foo1 provides the correct anchor name and therefore the correct interpretation via \autoref, while fig:foo2 (posted after a global change of \@currentHref within enumerate*) doesn't.
\caption[]{figure-caption\label{figure:foo} \begin{enumerate*}...– Ulrike Fischer Jan 25 '23 at 17:33