I've been told they can't be in the same cavity, regardless if it is 16" centers or 24" centers. An extra stud could be inserted if spacing and location is critical, effectivly isolating the two, I don't know what part of fire code it is in, if it is. I don't believe it's an electrical code thing. (facing opposite directions)
From the UL White Book
USE IN FIRE-RATED ASSEMBLIES
Listed single- and double-gang metallic outlet and switch boxes with metallic or nonmetallic cover plates may be used in bearing and nonbearing
wood stud and steel stud walls with ratings not exceeding 2 h. These walls have gypsum wallboard facings similar to those shown in Design
Nos. U301, U411 and U425, as covered under Fire Resistance Ratings ? ANSI/UL 263 (BXUV). The boxes are intended to be fastened to the studs
with the openings in the wallboard facing cut so that the clearance between the boxes and the wallboard does not exceed 1/8 in. The boxes
are intended to be installed so that the surface area of individual boxes does not exceed 16 sq in, and the aggregate surface area of the boxes does
not exceed 100 sq in per 100 sq ft of wall surface. Boxes located on opposite sides of walls or partitions are intended to be
separated by a minimum horizontal distance of 24 in. This minimum separation distance between the boxes may be reduced when Wall Opening
Protective Materials (QCSN) are installed according to the requirements of their Classification. The boxes are not intended to be installed on opposite sides of walls or
partitions of staggered stud construction unless Wall Opening Protective Materials (QCSN) are installed with the boxes in accordance with Classification
requirements for the protective materials. Listed metallic outlet and switch boxes with metallic or nonmetallic cover plates may be used in floor-ceiling and roof-ceiling assemblies with
ratings not exceeding 2 h when these assemblies have gypsum wallboard membranes. The boxes are intended to be fastened to the joists with the openings in the wallboard facing cut so that the clearance between the boxes and the gypsum wallboard does not exceed 1/8 in. The boxes are intended to be installed so that the surface area of individual boxes does not exceed 16 sq in, and the aggregate surface area of the boxes does not exceed 100 sq in per 100 sq ft of ceiling surface.