What parameters are important when replacing a rear hub? My rear hub is damaged. I have not yet inspected the source of the damage, but the wheel is moving sideways when rotating (a LOT), plus I rode it like this for about 35km. Therefore, I find it probable to soon need to replace the hub.

The rim and spokes are new (couple of months of commuting). I suppose I wouldn't be running in the "old spokes new hub" problem.

The old hub has 24 spokes. The disc rotor is attacked via 6 bolts.

What else should I know in order to judge if a specific hub will be a compatible swap (beyond that getting the exact same hub should work okay).
You need the: 


right width to match the dropouts you are fitting the wheel to (135 mm for rear hubs, 100mm for front typically).
same number of spokes as the rim you intend to use.
the right brake rotor mounting (center lock or 6 bolt).
the right axle width, diameter and fastening for the dropout (bolt thru, butted axle, quick release or thru axle (eg. maxle / maxle lite).


Putting the wheel together is a whole different matter, and there are tons of questions on wheel building here as well as entire books (like Brandt's The Bicycle Wheel). 

As for 24 spokes, I'm not sure I'd be comfortable with a 24 spoke wheel in most cases.