Contagious Synchronization and Endogenous Network Formation in Financial Networks