Because sys/socket.h is gratuitously including the things you need from sys/types.h.
For portability's sake, you must include sys/types.h also, as the gratuitous inclusion
is not mandated/required by any standards.
sys/un.h: UNIX protocol family related types/functions.
sys/in.h: Inet protocol family related types/functions.
Always observe the manual pages. If they say that you should #include specific headers to use a function or structure, then do it. Otherwise you don't need to.