Your instinct about using it in court as evidence is basically good - the 'hearsay rule' forbids testimony of the form 'so-and-so told me that the defendant was guilty,' with a few very narrow exceptions like the last words of a dying person that accuse someone of a crime. Because of teh 6th amendment, informants and undercover officers have to testify in court, where the defense can question them and challenge the veracity of their statements.
Of course this is not perfect. There have been cases where law enforcement or prosecutors told the informant what to say in an overzealous effort to gain a conviction, and sometimes innocent people have languished in jail for years on the basis of such false testimony. That shouldn't be allowed to happen, but when it does it doesn't necessarily mean the entire judicial process was corrupted. For example, a trial may have been properly conducted but if the defense lawyer was lazy or incompetent and failed to challenge the prosecution evidence the judge and jury may not have had any way of knowing about the flaws int he prosecution's case.
One important thing to bear in mind about American courts is that trial courts do not have an investigatory function to discover all the information about a case, but rather a decisive function to select between competing arguments from plaintiffs/prosecutors and civil/criminal defendants. So even if the defense lawyer is an obvious imcompetent the court inn't supposed to pre-emptively assist the defendant - the defendant has to ask for a new lawyer or bring up the issue at appeal.
In many other countries they use a different sort of system called civil law, where the judge is basically the lead investigator in the case. That can prevent some kinds of miscarriages of justice that occur in our system but as you might expect it opens to the door all sorts of other kinds.