The 'omitnan' option will ignore NaN values in your data when computing the mean. If your data contains values that result in a NaN being computed during the process of computing the mean then you'll receive NaN.
x = [1 NaN 2 3];
meanNoNaN = mean(x, 'omitnan')
x2 = [1 NaN Inf -Inf 2 3];
meanNaN = mean(x2, 'omitnan')
The NaN in the second element of x2 is ignored in the mean calculation. So we're taking the mean of five values: 1, Inf, -Inf, 2, and 3. As part of that mean calculation we need to add those five elements together using sum (as is normal for the standard arithmetic mean) and adding Inf and -Inf together results in NaN.
It's a bit subtle, but note that the documentation for the 'omitnan' option in the documentation for the mean function states "Ignore all NaN values in the input." [emphasis added] not "You can never get a NaN from this function if you specify this option." or something to that effect.
If you need to avoid even computed NaN values you probably want to remove non-finite values from your data before computing the mean. Use isfinite to identify those non-finite values or use rmoutliers to eliminate them.