This question already has an answer here:
The Siddhivinayak temple at Siddatek, is one of the Ashtavinayak temples. The linked wikipedia page mentions that
God Vishnu is supposed to have vanquished the asuras Madhu and Kaitabh after propitiating Ganesha here.
This is the only murti of these eight with the trunk positioned to the right.
Similarly, the government website of Siddhivinayak, Siddatek, mentions this legend of Siddhivinayak with a bit more detail and ends with
Lord Vishnu, sage Vyas, sage Bhrushundi, sage Moraya Gosavi, sage Narayan Maharaj were stayed at this holy place. This place is one of the twenty-one places of Lord Ganesha, which mentioned in the purana (mythology).
The question is, in which religious text has the legend of Siddhivinayak (about both Lord Vishnu's conquest of Madhu-Kaitabh) been mentioned and what are the verses which speak about him?