But your question arises more questions and analogies.
There is definitely similarities in the colors and patterns of each species, so is it innate (potential developmental pathway) or genetic?
But the environment definitely must have some factor too. Most gastropod species in deep sea do not have pigment, since no organism can detect color in those depths and would just waste its energy anabolizing unnecessary pigments.
Do genetic factors cause primary color and pattern formations, while epigenetic factors cause anomalies.
Maybe you can compare with the pre-existing studies on cephalopods and try to find analogies.