Yeah, that 'optimizing apps' message you see is the operating system recompiling the runtime processes of the apps and services you have loaded on the device. In 5.0 to 6.0.1, Google used a new runtime that took a very long time to compile all that stuff and could take a LOOOOOONG time if you had a lot of apps. Android 7.0 really streamlined that process and reduced that process time a great deal.
If it happened once, like people said, it might have just been a simple system update. If it starts to reboot often, popping that 'optimizing' message each time, then that might be pointing to an issue that might need a bit of investigating.