According to the end of the documentation of gdaldem, the code is an adaptation of the GRASS GIS approach, which is reasonably well documented here.
The central elements are (taken close to verbatim from the GRASS GIS documentation):
The aspect for slope equal to zero (flat areas) is set to zero (-9999 with -n flag). Thus, most cells with a very small ...
You could classify your raster trough the raster calculator with a simple formula like this:
("Slopes@1" > 15) + ("Slopes@1" > 30) + ("Slopes@1" > 45) + ("Slopes@1" > 60) + ("Slopes@1" > 100)
Each condition returns a 1 if true, so the raster output will have 0 values for source pixels less or equal to 15, 1 values for source pixels greater ...
Assigning new colors to the grid does not mean that the pixel values are categorized. The raster values remain untouched. The polygonize tool does not know anything about this categorization.
So first you need to reclassify the raster. Check this: Link and do it with the Grass r.reclass tool --> it works perfectly.
Once you have the ammount of categories ...
Here is an example of exporting a raster of slope and DEM for a country:
// Load the SRTM image.
var srtm = ee.Image('USGS/SRTMGL1_003');
// Calculate slope.
var slope = ee.Terrain.slope(srtm);
var elevation = srtm.select('elevation');
// Load a country border as a region of interest (roi).
var countries = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017');