Sometimes police officers sit in the spectator section of the courtroom (the gallery), waiting to testify. But there’s almost always another kind of uniformed officer in the courtroom: the bailiff.
The bailiff is an armed peace officer who is also a court official. (Bailiffs may also be deputy sheriffs.) There’s usually at least one bailiff in the courtroom—there may be more defending on the number and perceived dangerousness of defendants in court. There may also be additional bailiffs for crowd control—for example, if there is a particularly large group of spectators gathered to watch the case.
The bailiff’s job is to maintain order and decorum in the courtroom. Bailiffs have a wide range of duties, from removing disruptive spectators to telling attorneys where to stand when they address the judge. The bailiff also brings defendants from holding cells into court and escorts juries to and from the jury room and jury box.