11th gen overheating when plugged in

well when it shut off unexpectedly while looking at a pdf. it was very hot to the touch. then when i rebooted it was at 99C. i didn’t put a new load on the system that would cause that. it just suddenly spiked in temp then shut off. today it started to happen then i unplugged the charger and it stopped boosting the cpu unnecessarily. it doesn;t happen all the time just randomly when plugged into power it decides i want to run at 5Ghz all core now and push 38W through the cpu. idk why it is doing this.