Why do some non-alcoholic beers have sugar? I have seen non-alcoholic beers with anywhere from 0 to around 10 grams of sugar listed in the nutritional info tag. Is this added sugar? Or if it is just sugar from the process of making the beer, why do some have it and others don't? I have mostly seen German non-alcoholic beers with no sugar.
It could very well be natural or added sugar, it depends entirely on the style of beer and how it is produced.

The absence of sugar could be due to low sugar levels inherent in the substrates chosen for the beer. Or, it could be due to being fermented out. Keep in mind you can ferment things, have their sugar content reduced from the fermentation process, and end up with a beverage with only negligible amounts of alcohol. Think kombucha.

On the other hand sugar can be leftover from the fermentation process because the life form doing the fermentation (bacteria, yeast, etc) stalled before it could consume all the sugar. Saccharomyces cerevisiae, the yeast strain typically employed by bakers and brewers, does not like living in high-ethanol environments. That's why it's typically been a challenge for brewers and wine makers to get their alcohol content above the 5-10% range without undesirable components (congeners) being produced as a major side-effect. Alcohol is toxic to yeast!

Whichever way the sugar got there you can be pretty certain it's there for flavour! That could be direct flavouring: sweet things taste nice. It can also be there for balance: sugar "cancels" out acidity (and vice versa).