Well, the beastiary says:
"This type includes insects, arachnids, other arthropods, worms, and similar invertebrates."
The key word here is similar. Similar to arthropods and worms. "Similar in what way?" you may ask. Well, it says that later on too:
"A vermin-like creature with an intelligence score is usually either an animal or a magical beast, depending on its other abilities."
So it's not that an octopus has an intelligence score because it's an animal, rather, it's an animal because it has an intelligence score. The wikipedia page on octopuses says, "Octopuses are highly intelligent, possibly more so than any other order of invertebrates."