The particular instance I'm thinking of is the sack of Rome by Italian troops during the wars of unification. How could the largely Catholic Italians fight against the armies of the Pope without making themselves, in their own eyes, enemies of God?
There were a range of attitudes regarding Catholicism, the papacy, and the Papal States during the process of Italian unification. Some could not bring themselves to war against the pope. Others were downright eager to do so. However, such conflicts were nothing new. And I am referring to a range of conflicts here--from anticlericalism of various stripes, to warfare against the Papal States, to taking Rome from the pope by force.
Pius IX was elected in 1846. Two years later, he was in exile from Rome. He had to flee the city when the revolutions that swept Europe in 1846 reached Rome--and the need to flee was made manifest when one of his ministers was assassinated in broad daylight. A couple years afterwards he was restored to Rome by outside forces (French and Austrian, I believe).
So when in the following decade the process of Italian unification began to pick up momentum, it wasn't anything all that novel for the people of the Italian peninsula to find themselves torn between differing concepts of their identity. For devout Catholics, it could be difficult to take up arms against the papacy. For others, a desire to participate in unification overrode their hesitancy. For still others, there was no problem because they rationalized their actions as being against the temporal power of the pope--not his religious status. Others were eager to strike a blow against the papacy or Catholicism in general.
Still, there was something different about assaulting Rome itself. While most of the territory of the Papal States was in Italian hands in 1860-61, Rome stood until 1870. I can assure you that it was not from force of arms. There were a few concerns that applied to Rome that weren't as salient for the rest of the Papal States. The largest concern was that there was a contingent of French troops on loan to the papacy. Out of a desire to not go to war with France and Napoleon III, many in the leadership of the new Italian state refused to assault Rome. There was also a concern that unseating the pope (or appearing to do so) could lead to the same foreign intervention that had put Pius IX back into Rome after 1848--and the new Italian state hadn't nearly enough military power to resist such a move. Still, Garibaldi was quite eager to attack Rome--he just wasn't successful.
So why did Rome fall? Well, the French troops were recalled in 1870 (due to the Franco-Prussian War) so one big roadblock was removed. Italian troops attacked, Pius IX (still pontiff at the time) ordered that only a token defense be made, and Rome was now the capital of Italy. For his part, Pius IX declared himself a "prisoner of the Vatican." The ensuing struggle between the papacy/Catholicism and the new Italian state has filled reams of paper. A number of officials in the Italian government were excommunicated, including the King. In the case of the King--Victor Emmanuel II--the excommunication was only lifted just before his death. The pope also announced the policy of non expedit, which was a policy of non interaction with the Italian state. Catholics were to not participate in elections, either as candidates or voters. This policy varied in its application in the years leading up to the Lateran Accords in 1929, when such matters were settled on a somewhat permanent basis. Instead of an outright ban, the policy of non expedit was sometimes interpreted as a ban on electing subversive candidates. The ongoing difficulty of integrating Catholic identity with Italian identity (or other national identities, for that matter) was a difficult thing. There were a number of questions to be answered: What was the pope without his temporal power? What does it mean to be a Catholic in a liberal democracy? How does one balance loyalty to one's faith with loyalty to one's country? Many of these questions were still unresolved decades later. I would argue that most of them were still unclear after WWII.
The unresolved situation regarding the papacy was called "the Roman question," and it lingered from the fall of Rome in 1870 until the aforementioned Lateran Accords were signed in 1929. So, for nearly sixty years there was a good deal of tension between the nascent Italian state and the papacy. Only with the establishment of the Vatican City as an independent nation in that year did tensions finally begin to abate--only to be picked up again in the tensions between the papacy and Mussolini's regime in the buildup to WWII.
I hope that answers part of your question. I know I didn't focus on the particulars very much, but I wanted to cover a wider arc. Followup questions from OP and others are always encouraged though!