It's just more semantic and cleaner to have an id with words than the number. I would prefer that.
The problem is that the name of a category (which the code above uses) is not guaranteed to be unique, and so is potentially unsuitable for an ID. It could be okay for a class, but the uniqueness problem would still exist and make styling potentially difficult.
The database's id number may not be perfectly semantic, but it does allow tying the category entry in the database to a specific class for styling purposes.
Also, it's not correct to use ID's on the output from these functions in any way at all, as they are not guaranteed to only be used once on the page. I could easily have two different lists of categories displayed differently. Using a class is safer. The slug would indeed be fine as it is unique, but only as a class, not as an ID.