When shooting portraits or still life images the auto white balance seems to shift image from a cooler to warmer temperature and I’m not sure what’s causing it. Both flash and natural light. Nikon D780 in auto white balance, JPEG. It happens with different lenses, Nikon, Tamron as well. It’s almost like there’s something in the scene, maybe a color, that has the auto white balance confused.
Ahhh...the "curse" of auto-white balance. I don't use AWB and ... based on reading, it seems like few photographers suggest using this feature.
You did not mention a camera brand-model ... but that information would likely not change the response.
If you shoot 'RAW' (which preserves the maximum amount of data and post-processing adjustment latitude) then White Balance (for most cameras) is 'recorded' in the meta-data, but not actually applied to the image data. This means that if the camera got it wrong, you can fix it.
If you shoot JPEG, the White Balance is applied to the image (and you lose color-depth information... JPEG is 8-bit data whereas most cameras use 14-bit RAW data).
Optimal White Balance techniques rely on a 'known' neutral source (it need not be white and is usually a neutral gray). Auto White Balance doesn't have the advantage of a 'known' color-neutral target and tries to guess (for better or worse) -- so you're playing the odds when you use Auto White Balance ... and it often disappoints. The main point is ... you don't get to control the results (which puts you at a major disadvantage.)
I am not aware of any cure-all for White Balance reliability issues.
When color accuracy is important (it is not always important ... more on that later), use a neutral gray card to establish white balance.
I say "not always" because some photography would be ruined by accurate color balance. e.g. Sunset photography means blue light is absorbed by particles in the atmosphere and you get a preponderance of gold/orange/red (longer wavelengths wrap around the particles instead of being absorbed)... use of neutral gray cards to neutralize this color offset would probably ruin the artistic value of the shot.
Auto White-Balance guess color temperature by what is measured. This means that when the camera moves or subject moves, it can get different measurements which results in a different guess of color temperature. It is especially important if your scene has strong dominant colors.
There is also a factor from lights, depending on their type. Some lights to not emit a constant spectrum and they vary very quickly so that we do not perceive the difference within a cycle but the camera will measure colors differently depending on the light cycle.
Since you are using flash, many cameras have a Flash white-balance setting because the camera does not perceive the flash before it gets fired. This is the setting to use if flash is dominant in the scene.