I believe that zuchettos have their origin in the medieval practice of a cleric shaving the top of his head (not all of his hair, just a circle at the top of their head) when they were tonsured. Because of how cold the inside of churches could get, there was a concern about heat loss from the top of the head. A covering was created to prevent heat loss. The covering is the zuchetto.
Black zuchettos are worn by priests and deacons. Light purple/violet for (arch)bishops. Red for cardinals. White for the Pope.
The practice of priests and deacons wearing zuchettos as part of their clerics has fallen away (although they certainly may do so), while bishops really only wear theirs up until the Liturgy of the Eucharist, although they are part of their clerics when they wear a bishop’s cassock. I believe priests and deacons may wear theirs while celebrating Mass (same rule applies about removing it at the start of the Liturgy of the Eucharist), unless the Bishop is celebrating Mass, in which case the priest or deacon is not to wear theirs.