There are several different AIs that control how various creatures behave.
Hostile creatures will immediately try to harm your orcs or goblins.
Hungry creatures will first attempt to reach a stockpile that has food, and consume that food. If no food is accessible, the AI switches to Hostile.
This is the AI that controls how creatures under your own command will behave.