Please check the history books again. One of Bach's main works are his ecclesiastical cantatas. The Catholic Church has a complicated relationship with music. Partly forbidden at times, before that very polyphonic - depending on the epoch. Luther's concern, of course, was simplification - but Bach's great masses are a topic in themselves. Of course, there are also secular cantatas that were not performed in the church.
Of course the cantatas were performed in the church, but they are not really liturgical even if that can be argued (they were in some way there own liturgy).
As for the catholic church, music was never banned and was always extremely important, actually the mass used to be mostly sung for centuries. And you got the order backward, it was first monophonic, polyphonic music didn't even exist at the time, and purely vocal, even if the organ made it's way in the catholic church around the 10th century already. Gregorian became the official church music in the west, while the eastern churches went in a slightly different direction but with similar roots. The goal of Gregorian chant was to enhance the text and not to provide music for the sake of music even if in it's own way it can be sublime.
It's only around the 10th century that we had the very first examples of basic polyphony, with two voices moving mostly in parallel. It's also important to realize that at the time (like today), they were always the rules, but also more or less freedom as to how to do things. And the rules were usually changed once many people had already "broken" them and not the other way around. They were really more guidance than anything else. Which is why church music has been able to evolve so much and so fast.
Anyway, after this first experience of polyphony we already have the school of Notre Dame in the 13th century with very melismatic writing and a rhythmic approach with rhythmic cells that overlap that is more reminiscent of Steve Reich than of classical music
. I think that's when church music became much more independent from the text, which would allow it to become increasingly complex.
Move forward one century and in the 14th century you have music like the Messe de Tournai or Messe de Notre Dame that start having an approach to accidentals that breaks from the ecclesiastical modes and will eventually lead to tonality (but we are still far from that)
15-16th century, you have Josquin des Prez and as you can hear in the Misa Pane Lingua the various voices are now much more independent, they start the phrases at different moments, and we are getting a big step closer to tonality (which was obviously not analyzed as a V - I but simply as a combination of melodic movements to finish some phrases). You can also hear the use of cadences, especially the perfect authentic cadence, except that it was a development of the much older Clausula Vera and would never be thought of as a V - I.
By the end of the 16th century it's already Palestrina and we are ready to make the jump to tonality (the jump is a poor word as it was always a gradual change):
And then of course we get to Bach. And while Bach chorales were a direct effect of the protestant reformation, the rest of his music is right in the lineage of the music of the catholic church. It's also around that time that more complex orchestrations make their way in the church.