About two billion years ago, the first eukaryote cells evolved from the earlier prokaryote cells. These eukaryote cells also evolved a new way to move themselves around. Even though some eukaryote cells have flagella that look like the ones in prokaryote cells, they don’t work the same way. One did not evolve from the other.
Eukaryote flagella probably evolved from a cell part called the spindle, used during reproduction. Even though both kinds of flagella are made of protein, the eukaryote flagella are powered by small sugar molecules made in the cell’s mitochondria, not by protons.
Most eukaryotes are one-celled creatures, and they use their flagella and ciliae to move themselves around in the water to find food. But some eukaryotes are part of multi-celled creatures. You might think they wouldn’t need to move around anymore. But actually a lot of multi-cell eukaryote cells do still use their flagella or their ciliae.
For instance, there are lots of ciliae on cells inside your trachea (your windpipe, that you breathe through). These cells don’t move themselves, but they use their ciliae to push bits of dust or smoke or food out of your windpipe so it doesn’t get clogged up.
Another example is that sperm cells are eukaryote cells with flagella, and they use their flagella to swim over to the egg so that multi-cellular creatures from hydras to humans can reproduce.
How prokaryote cells move around
Bibliography and further reading about flagella: