I was pretty sure pi5 allows for multiscreens.
RPiOS can create a single 'desktop' over mutiple displays but then Kodi runs in a window on the desktop and you have to choose which desktop you want full-screen output on (as Kodi does not handle multiple screens) and you cannot 'adjust-refresh' display mode to suit the media being played (as Wayland does not allow this).
The closest you can get is stopping Kodi, editing config files with scripts to change outputs, then restarting Kodi. There is no way arouond the stop and restart because Kodi does not support dynamic change of video output.
I would describe the scripting approach as fragile. Feel free to experiment, but don't be surprised when it isn't reliable.