Role of the electromagnetic field in the formation of domains in the process of symmetry-breaking phase transitions