That depends on the value of GRUB_SAVEDEFAULT in /etc/default/grub.
If this option is set to ‘true’, then, when an entry is selected,
save it as a new default entry for use by future runs of GRUB. This
is only useful if ‘GRUB_DEFAULT=saved’; it is a separate option
because ‘GRUB_DEFAULT=saved’ is useful without this option, in
conjunction with ‘grub2-set-default’. Unset by default. This
option relies on the environment block, which may not be available
in all situations (*note Environment block::).
You then run grub2-mkconfig once and on next boot the saved entry will be saved to the last booted entry.
When using grub2-mkconfig one may use the command as sudo grub2-mkconfig -o /boot/grub2/grub.cfg
or sudo grub2-mkconfig -o /etc/grub2.cfg
or sudo grub2-mkconfig -o /etc/grub2-efi.cfg
all of which will actually output to the file /boot/grub2/grub.cfg as one can see here