In many animal species, evolution encodes objectives.
It is up to the individuals to figure out the behaviors that optimize these objectives.
Encoding objectives rather than behaviors is much simpler, more efficient, and more adaptive way for evolution to specify complex behaviors.
the same way it is much easier for human engineers to specify a loss function and rely on optimization for a system to perform perception or control than it is to design a perception or control system from scratch.