Short Answer: Paul wanted the Corinthians to address blatant immorality in the congregation, and to be able to work through legal disputes within the context of the Church, but he didn't want them going around criticizing people and fault-finding.
Words have a semantic range, so it is always important to look at what the author was attempting to communicate by reading each statement in context. Let's look at what Paul is talking about in each of these cases.
1 Corinthians 5:12 In Context
I wrote you in my letter not to associate with immoral people; I did not at all mean with the immoral people of this world, or with the covetous and swindlers, or with idolaters, for then you would have to go out of the world. But actually, I wrote to you not to associate with any so-called brother if he is an immoral person, or covetous, or an idolater, or a reviler, or a drunkard, or a swindler—not even to eat with such a one. For what have I to do with judging outsiders? Do you not judge those who are within the church? But those who are outside, God judges. Remove the wicked man from among yourselves. -1 Corinthians 5:9-13
Paul had previously written to them instructing them not to associate with immoral people. What he meant was that they should not associate with so-called "Christians" who were living immoral lives. What is in view here is not simply a person who stumbles here or there, but a person whose life is marked by some form of immorality. Well, the Corinthians were apparently confused by this instruction, and thought that he was telling them not to talk to non-Christians. His response here is: "of course that's not what I meant!" He points out how absurd that thought is by asking a rhetorical question: What do we (Christians) have to do with judging the lives of non-Christians? Nothing! But we do have a responsibility to recognize a person in the church who is living an immoral life and respond appropriately. In this context, "judging" refers to recognizing when a so-called "brother" is living a life of immorality. Christians are commanded to "judge" in this sense.
1 Corinthians 6:4-5 In Context
Does any one of you, when he has a case against his neighbor, dare to go to law before the unrighteous and not before the saints? Or do you not know that the saints will judge the world? If the world is judged by you, are you not competent to constitute the smallest law courts? Do you not know that we will judge angels? How much more matters of this life? So if you have law courts dealing with matters of this life, do you appoint them as judges who are of no account in the church? I say this to your shame. Is it so, that there is not among you one wise man who will be able to decide between his brethren, but brother goes to law with brother, and that before unbelievers? -1 Corinthians 6:1-6
Here Paul is talking about lawsuits, and taking your brother in Christ to court. He was outraged to find out that Christians in Corinth were dragging their brothers in Christ into secular courtrooms instead of settling their disagreements within the Church. In this context, "judging" refers to settling disputes between Christians. Christians ought to be willing to "judge" in this sense as well.
1 Corinthians 4:4-5 In Context
For this one it helps to know a bit of historical context (largely determined exegetically from a thorough reading of both 1 and 2 Corinthians.) The Corinthian church, which had been planted by Paul and served by Paul for many years, had fallen victim to false apostles who were essentially self-exalting extortionists. The Corinthians really liked these men who honored themselves and ripped off the church, but the more they listened to these false apostles, the less they thought of Paul and his companions. So many accusations had come forward from the Corinthians about Paul and his inadequacy as an apostle. So Paul had to put a lot of energy into explaining to them that he was in fact a credible apostle, and they were looking for the wrong kind of fruit in his life. You don't want a man who exalts himself and abuses the church, you want a humble servant, commissioned by God, who can bring the truth that Christ preached and who has a life that shows that he lives by that truth. Against that backdrop, here is the immediate context of the verse:
Let a man regard us in this manner, as servants of Christ and stewards of the mysteries of God. In this case, moreover, it is required of stewards that one be found trustworthy. But to me it is a very small thing that I may be examined by you, or by any human court; in fact, I do not even examine myself. For I am conscious of nothing against myself, yet I am not by this acquitted; but the one who examines me is the Lord. Therefore do not go on passing judgment before the time, but wait until the Lord comes who will both bring to light the things hidden in the darkness and disclose the motives of men’s hearts; and then each man’s praise will come to him from God. -1 Corinthians 4:1-5
What Paul is saying here is that he is a servant and a steward, and that his responsibility is to be faithful with what has been entrusted to him. He goes on to say that it doesn't really bother him at all if they want to scrutinize his life, because he's not aware of any glaring spiritual problems in his life. He concludes by exhorting the Corinthians to knock it off and stop criticizing him! He reminds them that the Lord is the One holding him accountable, and that the Lord will bring all things to light one day. They don't need to play "accuser of the brethren," or "adversary," or "fault-finders"... God is watching and God will bring all things to light. In this context, "judging" refers to critiquing someone's life. Christians need to be careful not to sit in God's seat in this matter.
Paul wants the Corinthians to stop scrutinizing his life and trying to find fault with him. He also wants them to stop ignoring blatant immorality in their church, and to stop taking their brothers to court instead of resolving disputes internally. Throughout the book he is urging these Christians to love each other and stop treating one another (and him) so terribly. It is terribly unloving to play the "fault-finder" in someone's life. It is also terribly unloving to overlook blatant, ongoing immorality in a person's life (both to that person and to the congregation.) It is also terribly unloving to drag your Christian brother into a secular courtroom instead of working things out in the context of the Church. So there is no contradiction here. Love one another and don't do nasty things. That's the theme throughout all of these passages. What makes it confusing is that the KJV uses "judge" in a whole bunch of different ways, and when we see the same word, we sometimes think it's the same concept. But a careful reading of the context will almost always resolve such alleged contradictions.