The problem is when a Villager doesn't have 'Offers', and the player right-clicks him, the score is not going to be added into stat.talkedToVillager. If you want to reproduce it, try summoning a Villager with no trades, and adding the sta.talkedToVillager objective, and then right click the villager to see how the score is not going to be added.
Might be invalid, see MC-106343.