To transfer contacts from iPhone to iPhone, using iCloud is the easiest method. Ensure both iPhones are signed in with the same Apple ID/Apple Account. On both phones, open Settings > tap your name > ...
You can transfer contacts from an iPhone to an Android phone using Google Drive, Gmail, or a "vCard" file.