You probably added yourself to the `www-data` group and didn't relogin afterwards. To change your group membership you can use
sg www-data
to get a new shell with the appropriate permissions.
groups will return the data from the database and not your effective permissions - from man groups:
> Print group memberships for each USERNAME or, if no USERNAME is specified, for the current process (which may differ if the groups database has changed).