In a criminal trial, the prosecution lawyer will often bring in the victim of the crime to say what happened, and anyone else who can prove the accused person did the crime. The defense lawyer will nearly always call up the accused person to explain why they are not guilty, and bring in other witnesses who can prove the accused person is not guilty. Each time a lawyer brings in a witness, the other lawyer will cross examine the witness - they will ask them questions to make sure they are telling the truth.
Witnesses have to swear to tell the truth during the trial. If a witness lies in court, it is known as perjury, which is a crime. A witness can be subpoenad, which means they are required to testify in court. If the witness does not testify when given a subpoena, they can be punished.