The English language has lots of words that are used in two or three different ways. For example, the word "cabinet" can mean "storage space in your kitchen" or "a group of folks who advise the president." Beer is a word with two meanings. It can mean an alcoholic beverage made from cereal grains, or a non-alcoholic beverage flavored by root extracts. Root beer, birch beer and ginger beer are three common forms of this non-alcoholic sort of beer.
In the case of root beer, the flavoring comes from the root of the sassafras tree or the sarsaparilla vine. Originally, the root was brewed like a tea to make an extract, but now it is much easier to buy the extract ready-made.
The root beer extract is mixed with sugar, yeast and water. If this mixture is placed in a tightly sealed bottle, the yeast will generate carbon dioxide at a high enough pressure to carbonate the water. You end up with fizzy, delicious root beer!