If the prosecution loses the case, it can be held liable in a civil case to losses the defendant made. So this is just an agreement between both sides to lower that risk and which does change nothing related to the case (so the judge will agree too). I guess, if there are no objections (even from a third party), this makes totally sense for anything else, too.