SkaveRat is addressing my original question: I'm asking if there is an advantageous reason for this phenomenon. You seem to suggest it's a spandrel at best, and fair enough, that could be the answer. It probably is a spandrel, I also believe that.
However spandrels usually don't reduce future chances or reproduction, and this one clearly does, so I was asking perhaps there is an advantage to this feature (not a spandrel then). Or at least an explanation for its existence from a genetic perspective, ie. the genes triggering the self destructing behavior are also the same ones responsible for a major survivability feature.
The reason behind spandrels existing can sometimes be explained other than "random", as it happens with the human chin for example - apparently someone figured out it's physically impossible for a chin not to appear if you are deforming maxillary bones to flatten into a face.
So far here nobody knows for sure about the octopus, and I gather it's because science doesn't yet have a consensus on the matter. But everyone has been quick to assure me it's just random and that there isn't anything else to it without any scientific backing.
Thanks, one solid answer! It could be that it used to be an advantage at some point and now it's just perpetuated