It was only recently (last few hundred years) that European states separated religion from the actions and authority of the state. Before it was an integral part of what gave their monarchs legitimacy and linked citizens of the nation together.
The separation grew out of conflicts between church leaders and state leaders, as well as Enlightenment thinking that religion should not have a role in politics.
I just finished an interesting book on the topic called Fields of Blood