To the OP, the theory that explains your fish’s appendage evolution is the theory of ‘scaffolding’.
What ‘scaffolding’ means is that a much larger structure was originally in place, perhaps a mass of cells some of which would sometimes light up, that over time was refined into only the portion that were actually beneficial for survival.
It’s a good question and shows that we do not believe that somehow the adaptation could ‘predict the future’ and say build up a stalk, then slowly curve it downward, then add the light at the end. I believe that is the heart of your question.
But if scaffolding occurred then we have a very different sequence of events. First a massive structure was created that in some occurrences had light emitting cells (many biological materials can emit light) and that this gave some advantage by luring in a meal.
The refinement into what you see however took a long time and happened by removing the portions of the structure that were not helpful or slightly harmful (too much extra mass to carry around). And I suspect that at some point the ability to move and swing that light source around gave a big advantage for luring in a meal.
Scaffolding is a valid biological concept, but further can be applied to any iterative design process. Evolution is just a description of how things change over long periods of time where there is scarcity of resources, and thus survival advantages can impact the direction of form into the future.
Darwin intended the ‘Origin of Species’ as a way to explain how life forms seem to exist in so many diverse forms, filling specific niches, thus having ‘specialization’. So evolution is the study of the dynamics of this specialization process. It is valid for many things other than just biological ones and is actually simple common sense.
For example, why is it that all of the furniture one finds at the antique store so well made? The answer is that all of the poorly made stuff isn’t around for you to see.
It is unfortunate that some take the ‘Origin of Species’ to mean the origin of all life. Perhaps that is just an unfortunate ambiguity of the English phrase. But Darwin was clear when he described that evolution is the theory of the process of how life changes, but does not explain the origin of life itself.
Evolution takes the existence of life for granted and just explains the process of change.
Evolution is just like the process of furniture making it into antique stores. We can see how over time only the well made and durable pieces can survive the process of being used and transported for over a hundred years. But this process in no way claims to explain how furniture itself comes about.