It's also possible to create files belonging to UID's and GID's that don't exist in some systems, someone might have extracted a tarball as root with -p and it preserved users down to the UID.
The OS is Android.
I investigated this further and realized that android has a single user setup. The usual /etc/passwd does not exist. Instead there are some hard-coded uid and gid in system/core/include/private/android_filesystem_config.h. But uid 501 or gid 20 are not defined.
Mounting the filesystem alone revealed that some files have root:root ownership. Some are not existent. So I infer it must be changed during init phase.
For now I know how to change it using chown. I still wonder how that uid 501 and gid 20 is coming into play? Some of these files must be extracted during boot since they do not exist prior boot and have a time stamp prior boot time.
Probably hardcoded, again. Without an /etc/passwd, they're not using any normal login system, just using setuid() and setgid() manually. Groups and users will have their usual meanings but no labels, and perhaps not even a way to check which users belong to what groups anymore. (scratch that -- /proc/pid/status may be useful there.)
The group ID may be arbitrary. The user ID 501 may be the first or second non-admin user; the first created on my system was 1000, but I've seen it start at 500 elsewhere.
Another possibility has occurred to me: You may be operating in a chroot, denied access to the /etc/passwd file.