When the State has a strong case, the State may offer the defendant a plea deal to avoid trial and perhaps reduce his exposure to a more lengthy sentence.
A defendant may only plead guilty if they actually committed the crime and admits to doing so in open court before the judge. When the defendant admits to the crime, they agree they are guilty and they agree that they may be “sentenced” by the judge presiding over the court — the only person authorized to impose a sentence. Sometimes the State will agree, as part of a plea agreement, not to recommend an enhanced sentence (such as additional time in prison for certain reasons) but it is left up to the judge to determine how the defendant will be punished.
If a defendant pleads guilty, there is no trial, but the next step is to prepare for a sentencing hearing.