A lot of food packages, nowadays, are mentioning "0 g sugar" or "sugar free". Then how do those still taste sweet?
There are plenty of sweet things that are not sugar(s)
People have a sweet tooth (or, to put it another way humans like sweet things). This is an evolutionary adaptation because fresh fruits are both good food (both nutritionally and in providing lots of energy) and rare in pre-modern food gathering cultures. So we are adapted to like things that are sweet as eating them is good for us (in moderation).
In the modern world we can have as much sweet stuff as we want but this is no longer a survival advantage as too much sugar provides more energy than we need to survive or thrive and eating it just makes us fat.
So the modern food industry has adapted to give us sweet-tasting things that don't overload us with unneeded energy. Many of those food ingredients mimic the sweetness of sugar without containing many calories, so allow us to eat sweet food without the same risk of consuming too many empty calories and getting fat.
There are many chemical that taste sweet but are not sugars. The successful ones tend to tase a great deal sweeter than the typical sugars found in fruits and related plants (glucose, sucrose, fructose and others). For example, aspartame is hundreds of time sweeter than sucrose but is a peptide not a sugar; Saccharin is an aromatic suphimide and is also hundreds of times sweeter than sucrose; acesulfame K is similar to saccharin.
There are also sugar-like sweetness that the body cannot digest but which taste sweet. Steria is a complex sugar with sweetness but few calories; Sucralose is a modified sugar the body can't digest so tastes sweet without containing the calories of sucrose.
The point of the claims on "sugar-free" foods is that they are sweet but non-calorific. Plenty of compounds can mimic the sweetness of real sugars like sucrose but are calorie free either because they are far sweeter (so much less stuff is required for the same level of sweetness) or because the body can't digest the compound and turn it into unneeded calories.
Most of the sweetening is done by using sugar alcohols such as xylitol, which allows producers to legitimately claim that there is "no sugar" in their products, as long as "sugar" is considered in the traditional sense (sucrose).
Stevia - another sugar substitute - is quite widely used. The Wikipedia entry states that as far back as 2006, stevia accounted for 40% of the sweetener market in Japan (for instance).