I can't say much of the Spanish Flu as it's far outside my area of expertise, but because churchmen were a very literate class and the papacy was very keen on record keeping, we actually know quite a lot about how Christian religious institutions responded to the Black Death. I am less knowledgeable about how Muslims and Jewish institutions responded.
The debate about whether to keep religious institutions depended heavily on what the locals thought to be the cause of the disease. There were the more medically minded who treated it as a physical thing in their environment that existed purely as part of the world, and that they as human beings had the power to manage and treat it, even if they did not yet know how. Physician Gentile da Foligno observed in 1348 that “communication of the evil disease happens principally from contagious conversation with other people who have been infected,” and Mariano di Ser Jacopo noted that “it happens often that men die of plague in healthy air simply through contagion.” Unsurprisingly, these people who identified that the disease could spread simply through contact with the sick tended to be against mass gatherings, such as church services or religious processions. One of the responses to the plague that was consistently seen as smart and effective was simply dispersing to country villages and avoiding major settlements - adherents to this included the pope who, having received reports from the medical communities of Italy concluding that it was untreatable, fled to the Alps to wait out the crisis (whilst still issuing instructions and conciliations by letter).
The second camp were those who thought the plague to me more mystical in nature; that it was a punishment sent by God. These people often favoured keeping religious gatherings, and indeed intensifying them, as a way to appease God. In Florence, it was recorded that the bishop led processions through the streets in an attempt to heal the sick, which included touching plague victims! The Bishop of Bath and Wells in England gave these orders as the plague was expected to arrive:
...arrange for processions... to be performed at least every Friday in every church, so that, abasing themselves humbly before the eyes of divine mercy, they should be contrite and penitent for their sins, and should not omit to expiate them with devout prayers, so that the mercies of God may speedily prevent [sic] us and that he will, for his kindness sake, turn away from his people this pestilence...
Naturally most churchmen fell into the second camp, whilst local governments usually fell into the first. Many local governments seem to have collapsed when the plague hit as their members rapidly died off or fled. For example, in Canterbury, the archbishop was one of the first to die, and so many of the cathedral's staff were sick that they did not formally elect a successor for over a year. Others, like Boulogne, managed to keep positions filled, but they were more focussed on just surviving and keeping the administration of the city going rather than passing measures to actually control the disease. But there were those places, like Milan and Tournai (in Belgium), where the local administration stepped up to the challenge and passed strict laws on social gatherings. In Tournai, the local church attempted to keep things going as normal, but the town council forced them to restrict gatherings. At first they restricted church services only to Sunday, then only permitted funerals, then only permitted two people and the priest to be at the funerals and banned post-funeral gatherings. Even the tolling of bells was banned, as they did not want locals to gather at the church to see what was going on.
The common restrictions were the following:
Also, many popular pilgrimage sites were closed. The Church of the Holy Sepulchre, the #1 place in all medieval Christendom, was locked shut and didn't reopen until the end of 1349, by which point the plague had clearly passed. It was the only time the site has been closed due to disease until our current pandemic.
So for the Black Death, many civil authorities passed very strict measures against places of worship. These tended to focus on funerals, which were seen as the main threat.