Actually, caffeine is added to sodas; the ones marked "decaf" simply don't have caffeine added.
Soda manufacturers buy caffeine from coffee makers, who have plenty of it, since they've removed it from coffee beans.
An article on NPR's Web site, "Caffeine For Sale: The Hidden Trade Of The World's Favorite Stimulant," explains there are various ways for the caffeine to be removed/separated from the coffee beans. For example, "'supercritical' carbon dioxide, a special form of the chemical that forms under high pressure, is pumped through the bed of beans ... '[this] penetrates the beans and pulls the caffeine out,'" writes the author, quoting a coffee-factory supervisor he interviewed.
He also summarizes another process, saying, "If you're a beverage maker looking for caffeine, though, there's also another source: big factories in China. Those factories accomplish, with lots of noise, heat and pressure, the same thing that a coffee tree does very quietly. They arrange atoms of some of the most common elements in nature — carbon, hydrogen, oxygen and nitrogen — into the particular structure of caffeine. Most of the caffeine that's used in the beverage industry is this synthetic version."
The NPR article is here:
http://www.npr.org/sections/thesalt/2016/02/26/467844829/inside-the-anonymous-world-of-caffeine