I'm guessing, some lower form of life, pre dolphin must have mutated the ability, but useless to them. Down the line, the dolphin was finally mutated, still having the same.
Cetaceans are thought to have evolved from semi-aquatic land mammals. (Prehistoric hippos, more or less.) It seems reasonable to assume that traits like larger lung capacity and higher CO2 tolerance were gradual, incremental gains that allowed these animals to venture further and further off-shore to hunt, or allowed them to stay submerged for longer and longer periods of time. Those with the mutant traits outcompeted the rest, and this process was cumulative. Whether concurrently or shortly thereafter, evolution transformed hands and feet into flippers.
To this day, whales have vestigial arm, wrist, hand, and finger bones in their front flippers. Baby whales of certain species are also born with a very light amount of fur, which they shed a few weeks after birth.
Fixation of a neutral allele within the population is proportional to its frequency in the population. So, even something that is initially useless can linger in the population, and even become fixed within the population. If that neutral allele is lingering in the population at a low frequency and suddenly becomes advantageous, there will subsequently be strong signals of selection at that locus.
Is it not possible for a combination of positive attributes to produce a useless attribute as a consequence, but the surplus attribute can't disappear as it's a manifestation of positive evolutionary traits that give you an advantage?