One of the rarest things that can happen to my phone is actually shutting down completely. It's to the point where it averages below once a year.
On my device, you only need to re-enter the sim code if you restart your device. I've switched phone numbers around 3 times this year and that alone probably makes it quite easy to guess what happened.
Another very rare thing to occur on my device is software updates. The last time I did updates was back in 2019. One thing I forgot was that software updates cause a restart... which then requires the sim code.
At least I had a backup plan for this exact scenario. I actually photographed my sim code so all I needed to do was remove the sim card and then unlock my phone.
The boy scouts motto of be prepared is definitely one that can appreciated.