There’s a slew of expository reasons for why the undead attack the living, depending on what film you’re watching.
Sometimes it’s because of a voodoo curse, other times it’s for a more science-y reason ( like it slows their metabolism, which keeps them from decaying). It can be a type of relief from the pain of death. It can be typical virus behavior, attempting to spread itself to as many hosts as possible. Or a more supernatural explanation, like hell spilling forth to literally consume humanity.
However, there is one universal truth that ( in my experience ) is just as valid as any I’ve heard. Old rotten flesh and cold coagulated blood taste like shit, but fresh meat that’s still warm? Now, that’s the stuff