The Church knew the earth was round when they were harassing Galileo. But you're conflating flat/round earth with helio/geocentrism.
The Church was not against Heliocentrism per se. When Copernicus first proposed the idea the response of the ecclesiastics who cared about such things was basically, “Well that’s very interesting. I rather like it. … Can you prove it? No? Too bad. Get back to us when you can.”
And in fact, all the observable evidence was against Heliocentrism … which is quite understandable seeing as it is in fact WRONG. The sun is not the center of the UNIVERSE and neither the planets nor the fixed stars orbit the sun in perfect concentric circles. The only thing the Copernican model got right is that the Earth moves. And though utterly wrong in the model of planetary and stellar motion, it did point in the right direction, that the cleanest mathematical model of planetary motion would eventually show the sun to be central-ish to that motion.
For the first 50 years after Copernicus published, all the theological denunciations came from Protestants, not Catholics. Luther, Calvin, and Melanchthon were all harsh religious critics of the theory. The few Catholics who took an interest rejected it on empirical rather than theological grounds. (Indeed, until telescopes were powerful and accurate enough to detect stellar parallax Heliocentrism was quite reasonably rejected as false.)
The Church’s problem with Heliocentrism began with Giordano Bruno, and it wasn’t the theory itself but rather what cranks like Bruno would infer from it. Assuming the truth of Heliocentrism, Bruno argued (correctly, as it turned out) that the reason why no stellar parallax was observed is that stars were all mindbogglingly far away. He then, in a fit of amazing genius, deduced that the stars were all suns in their own right. He then made the leap that they’d have planets in orbit around them too, including planets with sentient life! (And in AD 1578, too! Wow!) And then he ruined it all by claiming that each of these millions of planets with life on them would need Jesus to incarnate there to redeem them too, and that he would be so busy being born, living for 30 years, preaching for 3, and getting crucified, resurrected, and then ascending, jumping to each planet in turn, that he would NEVER have time to return to Earth let alone rule from Jerusalem for eternity or even a thousand years.
Bruno also denied the Virgin Birth, Transubstantiation, and that Jesus had human/mortal flesh, while preaching re-incarnation and some very heretical/mystical ideas concerning the Trinity, particularly in matters of Christology and the Holy Spirit, all while thumbing his nose at the Catholic clergy practically daring them to turn him into a human tiki torch. And this at the height of the Counter-Reformation when Catholicism was in a life-and-death struggle with Protestantism over the very issues of individual interpretation of Scripture and the authority of the Church.
The Inquisition accordingly had Bruno immolated in 1600. And for a generation after that Catholics were understandably prone to view anyone espousing Heliocentrism with a good bit of suspicion.
Galileo — not the most diplomatic or ingratiating of individuals — circa 1615 decided to really step in it. As the empirical evidence was against him, he employed aesthetic/philosophic arguments AND BIBLICAL ONES! (Yes. Galileo maintained the Bible taught Heliocentrism) And that’s what got him in hot water with the Inquisition — basically doing theology without a license, producing novel Biblical interpretations independent of and at variance with the Magisterium.
A year later, the Inquisition pronounced Heliocentrism itself heretical. But ultimately that was beyond its authority — only Councils and Popes could issue an absolute dogma on the matter. Neither ever did.
Another 15 years went by and Galileo was tempted to try again. He had a friend and protector in the then new pope, who enthusiastically allowed — arguably even commissioned — Galileo to pen a dialogue where the two opposing models were to be fairly debated ON THE BASIS OF SCIENCE alone. Galileo in turn composed and published a work that was anything but fair — or scientific — but was an opus for mocking the traditionalists, making the pope himself (obviously the main antagonist in the dialogue) look like a fool, and worst of all, again claiming that the Bible was on his side after swearing UNDER OATH that he would not! Thus he was condemned as a relapsed heretic and oath-breaker — and he was both! But his real crime was being insufferably obnoxious. But a martyr to “science” he was not.