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.
Best Answer
Excommunication seems to be a somewhat broken mechanic at the moment.
In fact you can only excommunicate another nation if their papal influence (the little number you see on the papacy icon) is lower than 5.
However, this is very unlikely to happen often, because gaining Papal influence is easy for most catholic nations and happens automatically.
The only way a country can drop below this boundary is if it just spent all its influence on a cardinal. So you can only get excommunicated if you raise your influence with the cardinals.
This does not make a lot of sense. As a comparison: In EU3 a country could get excommunicated when the relations with the Papal States dropped below 100.
So if you are really eager to excommunicate someone in EU4, keep an eye on the papacy tab. If you see that someone just raised their influence on a cardinal, you might have a chance to excommunicate them in the same month.