Beware of shonky explanations in online tutorials. It is not so much that atoms like to achieve filled shells, they more often respect them. Filling shells and subshells is generally more important because it marks the big gaps to the next shell or subshell, not because it is a magic number in itself. On the isolated bromine atom, straight forward energy reasons prevail. The energy order goes s d p. In molecules however, at least below fluorine, the s and p orbitals are close enough in energy to allow orbital mixing during chemical bonding, depending on the symmetry and energy of the other atomic orbitals. Then you can apply molecular orbital theory and you fill the MOs in order, not the AOs.Then it gets a lot more intetesting. You find that in molecular bromine for example that the pi bonding orbital is filled before the sigma bond, so your question was a good one, in that it always pays to check your natural assumptions!