An incomplete fermentation will result in an overly sweet beer. An improper mash will also yield more unfermentable sugars leading to a sweet beer. An improper balance of hops for the beer style being brewed will also cause a beer to be too sweet.
Make sure fermentation is complete before bottling. Use proper mashing techniques and make sure the conversion is complete. Pay close attention to the alpha acid content of your hops and adjust your recipe accordingly to achive the desired sweetness (or bitterness) for the style you are brewing.