These are state-issued so in case of people that share all those characteristics there's a system in place which changes just one character and gives a different result.
Every contract I signed and every interaction with the government required this information, so the kind of mishaps you talk about are not that common here (at least to my knowledge). Also, different from US social security numbers, this is not used as the only credential for important services, so keeping it secret is not needed (also, it can be manually derived in most cases, indeed you know the needed data. The algorithm is public).
One other thing that avoids confusion is that father and son can't legally have the same name.
EDIT: more info on the Italian Fiscal code https://en.wikipedia.org/wiki/Italian_fiscal_code_card