I know a tadpole can do this transformation, given enough time, so what about mermaids?
You either invoke magic, or they are really 'legs' that can 'velcro' together. It takes months for a small frog to change. On top of that frogs' tails don't split into legs, legs grow out from the base of the tail and the tail shrinks back into the body.
A similar process for mermaids I would think would realistically take years.
Adding: Merfolk could be amphibious, so that the young are born with tails, 'teenagers' are growing legs and adults have full legs to leave the water with.
Give them legs. They could be separate from birth and just covered with a swimsuit. Or they could be joined at birth and separate during puberty. These follow somewhat from some...
Real life precedents
Tiffany Yorks, Shiloh Pepin, and Milagros Cerron were born with a rare condition called sirenomelia or "mermaid syndrome", where the legs did not separate in the womb. Though Shiloh could not undergo separation surgery because her legs' blood vessels were too tangled, Tiffany and Milagros had their legs successfully separated. Both needed extensive rehabilitation to walk, and Tiffany's continuing mobility issues echo the admonition of the Sea Witch in H. C. Andersen's story that "at every step you take it will feel as if you were treading upon sharp knives."
A monofin is a paddle that clips to a swimmer's feet, giving more surface area for a dolphin kick. This leads to improved performance in swimming and free diving. Cloth covers for the legs and monofin allow professional swimmers to perform as mermaids in public. These covers are also sold commercially by firms such as Mermagica; others are custom-made.
Michael Phelps won a dozen Olympic golden medals for swimming in 2008 and 2012. In his autobiography No Limits, he attributes this to his long, thin torso, long arms, short legs, and large feet connected to hypermobile ankles. Pauli Poisuo of Cracked called him "basically a seal." Similarly, Icelandic fisherman Gudlaugur Fridthorsson swam for six hours in freezing water in 1984. After his full recovery, it was discovered that his body fat resembled that of a seal more than a human.
Francine DeGrood Taylor's answer that they are descended from humans who adapted to a semiaquatic lifestyle sounds like it's on the right track. But there are two ways this could go, even without any sort of magic.
One way leaning toward hard science is to make merpeople just a human ethnicity. This works well for "selkies," who can change between human and seal-like forms by putting on a sealskin wetsuit. Ethnic merpeople may resemble Sea Gypsies, with physiologic traits resembling those of Phelps and Gudlaugur, and wearing bamboo-tech monofins with a covering to hold the legs together and reduce drag.
Another more extreme adaptation might be to have babies born with webbed legs, similar to sirenomelia. The children prefer to move through water, not straying far from the beach or the river, because moving on land requires placing one arm and the heel forward and then pulling the butt up to meet them. (Shiloh demonstrates this technique in one of the TV documentaries about her.) Around puberty, hormonal changes cause the webbing to retract, separating into legs over the course of the next few years. Puberty would be a pain, as adolescents would need to learn how to walk from scratch.
Add a few more joints to the legs so they can bend right when acting as a tail, then reintroduce our vestigial tail as a long thin muscled membrane which can be wrapped repeatedly around the waist and chest when in biped mode, or can encircle the legs and spread out at the feet when in aquatic mode.
Serious genetic engineering required, but it might work.
Also, if you make the membranous tail (or tails) pretty, they might serve as garments when wrapped around the torso and groin, explaining why mer-folk are usually depicted as topless when shown in fish form.
What if the mermaids actually had legs (although legs that were jointed a bit differently) and those legs provided the structural support for the flesh cover of the tail? Perhaps their evolutionary trail led in the opposite direction from humanity's; they started out as bipedal (or tripedal?) beings and moved into the water. In order to move more efficiently, they developed fleshy extrusions that grew longer, long enough to encompass their legs. So, in order for the legs to emerge, the skin of their tails must be shredded. This would make it very painful (hence the similarity to the HCA version of the mermaid, whose mobility caused her terrible, cutting pain).
Or possibly the tail skin requires immersion in order to stay alive. If the skin is dried out, it dies and turns brittle and is "shed" so that the legs separate and the mer-person can walk. Once they return to the water for long enough, their bodies start producing a mucus-like substance that grows down to cover the legs (and perhaps fingers as well, giving them webbing). The mucus could cover the entire body, providing insulation and protection from the inevitable battering of an environment that is often in violent motion.