When we talk of ‘the church’, sadly we are usually referring to a system devised by humans, not all of whom have truly repented of sin and put their trust in Jesus. If Christ is not truly their Lord, and the Bible is not their guide, there will be issues which are seen as hypocritical and un-Christian. As in any organisation there are going to be scandals because every individual is flawed and, as in a computer programme, sin acts like a virus in the whole set up.
When the Bible speaks of the church, it is referring to the body of true believers, who are trusting Jesus, seeking to follow and serve Him in the Christian community of the church. Sadly though, they too will fail. A Christian is a sinner, who should be living in such a way that sin has become abhorrent to him or her. Every Christian still has a nature which does wrong, and sometimes sin comes to the fore. It has been like this since the beginning. Jesus warned about these things in His teaching, and many of the little books in our New Testament are letters written to churches to sort out errors in belief or behaviour.
I liken the church to a hospital, not a showroom. There is going to be mess, but God still meets with His people as they gather together. I spend a fair amount of time in churches, and despite heart-breaking times, generally speaking, I have found them to be places of immense love, care and refreshment.