Box selection is driven by three constraints: what it has to hold (a fan needs a fan-rated box anchored to structure, not just to drywall), how deep the assembly can be, and what the wall or ceiling material is. Old-work boxes grip the back of drywall; new-work boxes nail or screw to a stud or joist before the drywall goes up. Volume matters too, because box fill is a code calculation.
This group covers fan and fixture boxes, octagon and square boxes, old-work and new-work versions, extension rings, and the covers and plates that close them.