The gas is CO2, carbon dioxide, it's given off by yeast as they eat the sugar (they're farting). The CO2 they give off, if trapped in a bottle, will eventually go back into the beer, giving it carbonation.
With kegs, you can use sugar, but you'll be using less sugar than you would if you were bottling.
Most people who use kegs don't use sugar, they buy a CO2 tank and get it filled with CO2 - they force the CO2 into the beer to carbonate it. It can be done quickly, in as little as a few days, but the proper way to do it takes about 2 weeks, which is about how long bottling takes