I've experienced this before too when using VirtualBox (I'm not sure what you're using, so I'll explain what you can try if you are using VirtualBox).
It's likely that your guest needs more video memory and that you need to switch to
VBoxVGA as the graphics controller. You can choose all these options in the VM's settings.
This seems to be an issue with VirtualBox and KDE. If you want to read more, you can check https://www.reddit.com/r/kde/comments/bp11e8/kde_neon_under_virtualbox_changing_screen/.
If your end goal is to have your VM viewport resize to your host's window, you can install VirtualBox Guest Additions on your guest instead of fiddling with the resolution settings.
This also seems to happen when using VMware. If that's the case, increasing video memory and enabling acceleration might also fix it. Read more at https://www.reddit.com/r/kdeneon/comments/bsgn73/vmware_workstation_15_pro_and_kde_neon_display/.