From the OP, specific to the use case of Geany and Nautilus under Gnome... this is mutter's focus-stealing prevention at work.
I found this still-open issue here as I was searching for a feature request with Geany to implement the [XDG Activation protocol](https://wayland.app/protocols/xdg-activation-v1).
A nice explanation and discussion of [how it all works](https://discourse.gnome.org/t/understanding-gnome-shell-s-focus-stealing-pre...) was recently posted on Gnome Discourse. That reminded me...
...For a long time now, and specifically to solve the use-case noted in the OP, I've been employing [a very simple extension](https://extensions.gnome.org/extension/6385/steal-my-focus-window/) to work around this issue, and to immediately focus Geany when opening files from Nautilus file manager.
One key point missing from the OP is that if Geany is not running, the first time a file is opened from Nautilus, a Geany window will open and gain focus. I.E..
1) With no Geany instance running, click to open txt file from the Nautilus UI (Geany opens a new window and it gets focus). 2) Click to open any number of subsequent files from the Nautilus UI (files _are_ opened in Geany, _but_ the existing Geany window does not get focus (and the ["...is ready" notification toast](https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/358) is displayed) in Gnome. This is the focus-stealing prevention.
Should a new issue be filed specifically to request the XDG Activation protocol implementation in Geany?