Civil law has generally recognised the confessional seal. For example, priests can’t be compelled to testify on anything they hear in the confessional.
Another example is attorney - client privilege.
Attorneys and priests are expected to do important duties for the good of society and thus have certain privileges.