It only happens when the battery is aging and the iPhone would otherwise shutdown since it can not handle the voltage peaks. Since the reports Apple has now a battery health section in settings which warns actively when you need to replace the battery. For example my father just replaced the battery in my old 2015 6S plus and it works on full speed again.
I should point out that the Samsung CPU speed thing was designed to save battery power, I guess the assumption being you only need full power when playing a game and when playing a game you’re touching the screen. Well intentioned but not much good for our app which integrated with a Bluetooth MIDI keyboard so users didn’t touch the screen at all!