I think it’s natural for people to react in two specific ways to signs of external threats: 1) reconsolidate their notion of community along more homogeneous lines (thus reducing the perceived risk of infiltration or betrayal by heterogenous members), and 2) idealize their values as metaphysical givens rather than moral aims (thus relieving some of the anxiety around whether those values will survive).
Both of these trends are inimical to a faith that can renew itself and make itself relevant to new generations, which is probably why religiosity seems to be in a moribund cycle of disaffiliation in the West.