@Stephen The context of
1 Timothy 5:
Elders who do their work well should be respected and paid well,[e] especially those who work hard at both preaching and teaching. 18 For the Scripture says, “You must not muzzle an ox to keep it from eating as it treads out the grain.” And in another place, “Those who work deserve their pay!”[f]
19 Do not listen to an accusation against an elder unless it is confirmed by two or three witnesses. 20 Those who sin should be reprimanded in front of the whole church; this will serve as a strong warning to others.
I solemnly command you in the presence of God and Christ Jesus and the holy angels to obey these instructions without taking sides or showing favoritism to anyone.
22 Never be in a hurry about appointing a church leader.[g] Do not share in the sins of others. Keep yourself pure.
23 Don’t drink only water. You ought to drink a little wine for the sake of your stomach because you are sick so often.
24 Remember, the sins of some people are obvious, leading them to certain judgment. But there are others whose sins will not be revealed until later. 25 In the same way, the good deeds of some people are obvious. And the good deeds done in secret will someday come to light.
Paul's words mean something specific to the audience here. It sounds like there is much gossip about alleged sins of an elder. Paul is trying to teach them to handle this in a Gospel way.
The Scripture in Matthew says "if a brother sins against you." Instead of being upset, gossiping, the brother is instructed to go to the other brother and let him know. If the situation does not get resolved, he should bring other brothers or elders together in the matter.
Regarding
1 Tim 5:20: Timothy is told there are times are when not only an elder should be rebuked, but times when he should be rebuked publicly.
This is a good reminder that leaders who fall into a life of sin, or evil wrong-doing should be accountable to the people, and not just tucked under the carpet with a sudden pastoral departure. The people should see with leaders what sin is, how vulnerable we all are, and that there's no place for a lifestyle of sin with those who desire to lead the Church.