As long as the beak fits, the whole octopus can squeeze through it!

For humans to keep an awareness of our relative body position and where we are is fairly simple, we have a small number of moving pieces, and well-placed sensors that monitor their relative positions. Humans tend underestimate how much more cognitative ability this simple task requires from an invertebrate with only one solid part.

I think that that alone may be enough to answer the question about why octopi would have well-developed cognition abilities.

Cheers,
Ben

PS This point stolen shamelessly from [link|http://www.amazon.com/exec/obidos/tg/detail/-/0198602243/102-2249789-8394563?v=glance|The Oxford Companion to the Mind]. (A classic. Dated, but classic.)