Your iCloud and Gmail contact lists are separate. The "All Contacts" list shows both iCloud and Gmail contacts together, but they are not merged. If you want to edit a Gmail contact, go to the Gmail list to make changes; it won't affect iCloud contacts. If you have the same contacts in both accounts, either remove them from the less-used account or edit the contacts on both accounts individually.
In summary, you maintain two (Only 2) distinct contact lists that operate independently of each other.
Unlike some Android devices, contacts are neither stored locally on an iPhone nor in SIM. They are synced to an email account that you have Google, iCloud, AOL, Exchange, Outlook, Yahoo or any Other