Maybe Hit Dice and character levels are the same thing?
In Pathfinder's antecedent Dungeons and Dragons 3.5, Hit Dice and levels were functionally the same thing and could be used interchangeably. Pathfinder, however, seems to have left whether or not Hit Dice and levels are equivalent just ambiguous enough that a GM could rule either way. Threads from 2014 (that's also, by the way, in response to exactly this question) and 2018, for example, fail to reach definite conclusions and, instead, seem to end in a draw, both sides bloodied and panting in their corners.
(As an aside, practically, this GM finds it acceptable for a creature to count its Hit Dice as levels for meeting a feat's prerequisite: a pit fiend, for example, should be able to attract a cohort and followers without needing to have, like, 7 levels of fighter on top of its other abilities! This GM just can't imagine a potential cohort saying, "O, wait, you're just a pit fiend? Sorry, man, but I can't be led by a dude unless he has at least 7 levels in an actual character class. I'll only follow someone with real experience." That's kind of insulting to both the pit fiend and the interviewee! However, that's solely this GM's opinion, and another GM may have totally different feelings on the matter.)
A GM would likely have only highly unusual animal companions take the feat Leadership
Fortunately, the case of an animal companion taking the feat Leadership shouldn't ever come up. That is, even if the GM rules that an animal companion could take the feat Leadership, only in the most unusual of cases would the GM have the animal companion actually take the feat Leadership. See, while the PC may have a class feature that grants the PC an animal companion, it's the GM—not the player—who builds the animal companion: "Aside from the players, everyone else in the game world is a non-player character (NPC)," says Creating NPCs. "These characters are designed and controlled by the GM to fill every role from noble king to simple baker."
So, although animal companions use different rules for their creation than the typical NPC noble king or simple baker, animal companions remain nonetheless just like that noble king or simple baker in that animal companions are designed—and, likewise, controlled (but see this question)—by the GM. This means that the GM will probably have an animal companion take almost any other feat before he has the animal companion take the feat Leadership!
(Seriously, read strictly, after the player picks the kind of animal companion his PC receives, the only other thing the player gets to pick for his PC's animal companion is that animal companion's bonus tricks. Even ability score increase says, "The animal companion adds +1 to any one of its ability scores," rather than "The character adds +1 to any one of his animal companion's ability scores," or whatever.)