The WrapMode that the animation system uses for a specific animation is determined this way:
You can set the WrapMode of an AnimationClip in the import settings of the clip. This is the recommended way to control the WrapMode.
When an AnimationState is created, it inherits its WrapMode from the AnimationClip it is created from, but you can also change it from code.
If the WrapMode of an AnimationState is set to Default, the animation system will use the WrapMode from the Animation component.