Entities don't have the NoAI tag by default. It's only accessible if you add it through the summon command or /data. So instead of detecting if the value is 0, you can detect if the tag is assigned or not:
/execute as @e[type=cow] if data entity @s NoAI run say 1
/execute as @e[type=cow] unless data entity @s NoAI run say 0
Another reason why your command didn't work is that you need to use the correct data type when testing for NBT. The value of the NoAI tag is a byte so you need to include the letter 'b' after the value (1b).