Ooh boy, serial endosymbiosis is really something.
(source: Patrick Keeling, 2004, The Number, Speed, and Impact of Plastid Endosymbioses in Eukaryotic Evolution)
So basically bacteria invented photosynthesis a bunch of times, but oxygenic photosynthesis, the kind that breaks water molecules to make oxygen (which is a lot easier than using e.g. hydrogen sulfide, but also requires a more complex apparatus, it's actually a really interesting adaptation) appeared exactly once, among Cyanobacteria. However, photosynthesis, especially the oxygenic kind, is a really really useful trait. The way most photosynthetic organisms on Earth accomplish it is by swallowing someone else who is already photosynthetic.
Eukaryotes -- i.e. all life on Earth with a nucleus in their cells, or if you will everything living that is not bacteria and such -- got their start in the first place by engulfing smaller oxygen-breathing bacteria that became mitochondria, so they (we) already have some good experience in that. A clade of Eukaryotes called Archaeplastida engulfed Cyanobacteria, turning them into plastids, granting themselves the power of photosynthesis. (This is primary endosymbiosis, as was the earlier origin of mitochondria. Both mitochondria and plastids are surrounded by two membranes -- their own old bacterial membrane, and the internal membrane of the host cell). From the first Archaeplastida grew red algae, green algae, and then the plants with roots and leaves we're familiar with. Some success!
However, the first Archaeplastida made themselves a target, just like Cyanobacteria had done. Not just for grazing, but for endosymbiosis too. At some point, members of several other clades of Eukaryotes -- Haptophyta, Cryptomonadida, and possibly the ancestors of a large and diverse group recorded as SAR -- engulfed unicellular red algae in turn. (This is secondary endosymbiosis. The resulting plastids have four membranes: the original bacterial membrane, the inner & outer membrane of the red alga, and the inner membrane of the new host.)
Other groups -- the flagellate Euglenids and the spiderweb-like Chlorarachniophyta -- did the same by engulfing unicellular green algae instead. (See my Tree of Life series for more info on all these groups.)
The SAR group did well: its photosynthetic lineges include diatoms, giant kelp, and the Dinoflagellates responsible for red tides. Other lineages are not photosynthetic, though, so either they lost their chloroplasts, or those other group did in fact acquire them independently. Ciliates like Paramecium, for example, lost or never had them. (Well, actually some Paramecium incorporate green algae, but not to the point of endosymbiosis.) Inside SAR we also find Apicomplexa like the agents of malaria and toxoplasmosis, which modified their chloroplast into a structure that can't do photosynthesis anymore but helps with other biochemical processes.
it doesn't end here. Dinoflagellates got creative. Some cast aside their red chloroplast and acquired a new one by engulfing a green alga instead. Others, multiple times, independently, engulfed diatoms or haptophytes. Tertiary endosymbiosis! A cyanobacterium inside a red alga inside a diatom inside a dinoflagellate!
... And meanwhile the armored amoeba Paulinella started all over again with primary endosymbiosis by engulfing a different Cyanobacterium, unrelated with all the rest of this story.
And now, just a couple weeks ago, the discovery was announced of the nitroplast, a chloroplast-like organelle that was also the result of endosymbiosis of a Cyanobacterium. This happened in a Haptophyte, and this time the point of the endosymbiosis does not seem to be photosynthesis but nitrogen fixation (i.e., breaking the infamously hardy molecules of nitrogen in the air to incorporate their atoms in a form easier to digest. Legumes can do that too, thanks to symbiont Cyanobacteria in their roots, but not so directly.)
For bonus weirdness points: the Haptophyte carrying the nitroplast has an armored stage of its life cycle that looks like a perfect dodecahedron:
Ah, but of course plenty of animals would find photosynthesis useful as well.
OP kindly mentions corals, many of whom have incorporated red algae in their tissues to provide some extra sugar. Many other low-metabolism animals did the same with green algae or cyaniobacteria. There's even a slug, Elysia chlorotica, that sucks chloroplasts from the algae it grazes, incorporates in its own tissues, and keeps them running long enough to do some photosynthesis on its own -- Elysia's body even looks like a leaf!
Indeed, George McGhee's Convergent Evolution on Earth (which admittedly might err a tad to the side of more convergence) lists 14 events of photosynthetic endosymbiosis among protozoa, and 19 among animals, including sponges, cnidarians such as corals, flatworms, sea squirts, clams, and slugs.