The on-surface polymerization of 1,3,6,8-tetrabromopyrene (Br4 Py) on Cu(111) and Au(111) surfaces under ultrahigh vacuum conditions was investigated by a combination of scanning tunneling microscopy (STM), X-ray photoelectron spectroscopy (XPS) and density functional theory (DFT) calculations. Deposition of Br4 Py on Cu(111) held at 300 K resulted in a spontaneous debromination reaction, generating the formation of a branched coordination polymer network stabilized by C-Cu-C bonds. After annealing at 473 K, the C-Cu-C bonds were converted to covalent C-C bonds, leading to the formation of a covalently linked molecular network of short oligomers. In contrast, highly ordered self-assembled two-dimensional (2D) patterns stabilized by both Br-Br halogen and Br-H hydrogen bonds were observed upon deposition of Br4 Py on Au(111) held at 300 K. Subsequent annealing of the sample at 473 K led to a dissociation of the C-Br bonds and the formation of disordered metal-coordinated molecular networks. Further annealing at 573 K resulted in the formation of covalently linked disordered networks. Importantly, we found that the chosen substrate not only plays an important role as catalyst for the Ullmann reaction, but also influences the formation of different types of intermolecular bonds and thus, determines the final polymer network morphology. DFT calculations further support our experimental findings obtained by STM and XPS and add complementary information on the reaction pathway of Br4 Py on the different substrates.