The decision to plead guilty or go to trial rests entirely with the defendant. Your attorney will advise you of your options and all the consequences and possible outcomes. But the decision to continue fighting the charges against you is yours to make. And sometimes no matter how much you want your day in court, the risk of losing is too great.
If the prosecution offers a plea deal to your attorney, your attorney will tell you about it and explain the consequences. If you don’t have a strong defense and the consequences of losing at trial far outweigh the consequences of the plea deal, you may decide that pleading guilty is your best option. Even if you have a strong defense, you cannot predicate what decision a jury will make. Sometimes the known is a better option than the unknown. The majority of criminal cases end with a plea deal rather than a trial.