You already have an answer in your own question.
When the PC is pluggled it can focus on performance, raising the clock and a lot of others stuff that would consume more energy due to it being plugged and having a 'infinite' power resource.
Then the PC is on the battery, it's has a limited resource so it will use less, running at lower speeds to save energy to last longer, it also underclock itself a lot when nearing the end of the battery to try to prolong a bit more until it gets recharged.
To put it simply, it completely normal for a laptop to do that. You could try to set Performance mode when using battery as well, it will probably improve your gaming experience while not charging but also shorten the duration of the battery, so i'd game while plugged anytime.
To put simply, it will