You can't merge Contacts on different email accounts using an iPhone.
An example for exporting Contacts from iCloud to Yahoo
Log in to https://www.icloud.com using your Apple ID credentials Tap Contacts app > Settings > Export vCard.
iCloud will import or export only vCards.
You need a third-party app to convert vCard file to CSV as Yahoo will only import using CSV file --> Import, export or print contacts in Yahoo Mail - SLN28070
An example for exporting Contacts from Gmail to iCloud
Unlike some Android devices, contacts are neither stored locally on an iPhone nor in SIM. They are synced to an email account that you had Google, iCloud, AOL, Exchange, Outlook, Yahoo or any Other
Try to export the contacts from google mail on a web browser. During Export select export as vCard and then
log in to https://www.icloud.com using your Apple ID credentials Tap Contacts app > Settings > Import vCard.