Copy first, then open — not the other way
The template stays intact because you call DriveApp.getFileById(templateId).makeCopy() before touching SlidesApp at all. The copy lands in your output folder and gets a new file ID. Only then do you open it with SlidesApp.openById(). Opening the original and editing it in place is the mistake that corrupts your master slide.
replaceAllText() is a presentation-level method on a Slide object, not on the Presentation. Call it on each slide you need to modify. For a single-slide certificate, pres.getSlides()[0] is the whole job. If your template spans multiple slides, loop over pres.getSlides() and call replaceAllText on each.