If you plead guilty to an offense and the judge accepts your plea, there will be no trial. Prosecutors accept plea bargains for two main reasons:
They fear that their evidence is not enough to guarantee a conviction; or
Their dockets are busy and they wish to save the time and effort of a trial.