I found about why Shiva and Vishnu become Harihara from this chapter of
Skanda Purana.
8-10. I shall suggest a means to be placed before you all who have taken resort to excellent Dharma (righteousness).
Once devotees of Śiva had a great dispute. They quarrelled with the devotees of Keśava. They wanted to gain victory over one another. Thereupon, even as his devotees were watching, Lord Rudra assumed a wonderful form with an idea of bringing about peace with the Gaṇas of Viṣṇu. With the halves of each boḍy he assumed the form of Hari-Hara.