Contacts are escaping to Google

Today I tried to phone someone from my car only to find no entry under that name and when I looked at my contacts a proportion were missing. On the Macbook I found these had mysteriously moved under the Google heading and no longer were showing under the On My Mac heading. The only synching I had done was with the iPhone and iPad not with any android phone. Incidentally the iPad is still unaffected.
I have a Gmail account on both devices but only the Gmail app on my iPhone.
Is there an easy way of moving the contacts back to On My Mac with out retyping them? How can I stop this reoccurring?