Clearing your data (or "factory reset") is when you put your phone back to the state it was in before you turned it on for the first time
eg: Standard or no wallpaper, original settings for your homepages, all downloaded apps removed.
Clearing your cache removes all files (temporary or otherwise) from your phone's RAM, meaning your handset will run a bit faster because there's more buffer memory to put data in.
Google will already have your data stored in another file not in the cache so when you clear your phone's cache, you can still log in.