UPDATE: According to recent changelogs, the bugs regarding Legatus Natus and PrimasGermaniae are fixed in Patch 1.4
Here the old answer with an explanation of the bug:
I just checked the event files for both events (LegatusNatus.txt and PrimasGermaniae.txt).
They behave pretty much in the same way, so I will only write it up for LegatusNatus.
From what I can gather, Mainz gets the title automatically within one month:
# Legatus Natus
country_event = {
...
trigger = {
papacy_active = yes <-- Pope must exist
tag = MAI <-- This only happens to Mainz
exists = yes <-- Mainz must exist
is_elector = yes <-- Mainz must be an elector
government = theocratic_government <-- Mainz has to be a theocracy
NOT = { has_country_flag = happened_763 }<-- The event has not happened yet
}
mean_time_to_happen = { months = 1 }
immediate = { set_country_flag = happened_763 }
option = {
name = "EVTOPTA763"
add_country_modifier = {
name = "legatus_natus"
duration = -1
}
}
}
And this is where things go wrong. For Mainz to get the title there is no need for a good papal relation, and Mainz starts out with a low one in fact.
However, the event for losing the title is as follows:
# Position as Legatus Natus Revoked
country_event = {
...
trigger = {
has_country_modifier = legatus_natus <-- Country must be legatus natus
OR = { <-- and either of the following is true
capital_scope = { is_part_of_hre = no } <-- not part of the HRE
NOT = { government = theocratic_government } <-- not a theocracy
NOT = { religion = catholic } <-- not catholic
NOT = { has_opinion ={ who = PAP value = 100 } } <-- not 100 relations with the Papal States
exists = no <-- Country not existing
}
}
mean_time_to_happen = { months = 1 }
option = {
name = "EVTOPTA964"
remove_country_modifier = legatus_natus
set_global_flag = no_legatus_natus
}
}
So within another month after getting the title Mainz will lose it again due to the Papal States not having an opinion of 100 of Mainz.
If that's no bug, I don't know what is.
I guess Mainz should either get good relations with the Papal States from the beginning or only get the title after they hit the 100 relations threshold.
Also the info text for losing the title is highly confusing. Nowhere does it say that you have to have good relations to the Papal States.
I just tested this under the latest version of 1.9 on non-Ironman by playing as a Japanese daimyo, annexing another daimyo through console, and releasing them through the "Release Subjects" dialog. They remain your vassals, even after monthly/yearly ticks.
Best Answer
You can't be excommunicated if the papal state has positive opinion of you.
The papal controller can excommunicate any catholic nation that the papal state has a negative opinion of. Fortunately you can just improve relations with the papal state to avoid this as you can't be excommunicated if the papal state has positive opinion of you.
Or, you can drop Provence and ally the Pope. :)