When it comes to the Confessional there are two sets of laws that cover what is heard during someone’s confession. In some places civil/criminal law of the State protects the confidentiality of those things heard in the confessional and Doctor’s office. However if a Doctor or Nurse hears someone say, I’m going to go to the tallest building in the city and thow myself off after this office visit, they can call the police and say, “You need to come to the office and get Mr. X who is threatening to kill himself or someone else.” and not have to worry about violation of HIPAA privacy laws. A priest may call the police and say you need to be on the watch for a suicidal person at the tallest buildings around town. But cannot pinpoint the person. The reality is there may be more than one life contemplating suicide which may be saved, but the individual cannot be identified.
As to Civil vs Canon (Church) Law. Civil law in most places honors the priest as having to uphold the seal of the confessional, however does not usually give the same rights to somone who overhears a confession. Canon (Church) law includes anyone who overhears the confession, it does not matter if they do so legitimatly or not. An example of someone who may overhear a confession in a legitimate matter would be if someone needed to go to confession but did not speak a language that the priest understood. Someone could with the permission of the person confessing translate for the priest and penitent, however they must be instructed to only translate, and not add or omit anything the priest or person says, and that they are bound by the seal of the confessional, and cannot reveal anything heard in the confession. This also includes asking the person or priest about something discussed in the confession afterward. This also includes sign language translation.