The formation of bubbles in a flow-focusing (FF) junction comprising multiple rectangular sections is described. The simplest junctions comprise two sections (throat and orifice). Systematic investigation of the influence on the formation of bubbles of the flow of liquid and the geometry of the junction identifies regimes that generate monodisperse, bidisperse, and tridisperse trains of bubbles. The mechanisms by which these junctions form monodisperse and bidisperse bubbles are inferred from the shapes of the gas thread during breakup: these mechanisms differ primarily by the process in which the gas thread collapses in the throat and/or orifice. The dynamic self-assembly of bidisperse bubbles leads to unexpected groupings of bubbles during their flow along the outlet channel.