Actually, I figured out a work around, but the work around is still cause for concern, because it just shows it should not have happened in the first place.
Here is the setup. One of my main synthesizers for MIDI input is a Roland Fantom-6 EX. Roland's MIDI driver for the Fantom has 3 inputs (see below).
I had to turn off the FANTON-6 7 8 DAW CTRL input to stop Logic from triggering MIDI every time I switch out of the app. I would like to re-iterate here that the problem is when I switch out of the app, Logic will trigger MIDI random notes in of a Software Synth if that DAW CTRL if left on (and its input is NOT routed to the software instrument track).
Granted, I will admit part of the problem is Roland's MIDI and Control surface drivers for the Fantom-6. In particular the Logic Control Surface driver for the Fantom are written for the macOS Intel Architecture, and have not been updated to the ARM-64 M-Series Architecture. So you cannot use Fantom as a Control surface unless you run Logic in Rosetta mode (which I think is unacceptable). (So if Apple could put some pressure on Roland to keep their drivers updates with all the current architectures, I would appreciate that, because they have a really bad habit of build and forget.)
However, the driver issue does not let Logic totally off the hook, because it when I am NOT using the Fantom as a control surface, therefore NOT running in Rosetta mode, and just happen to have the DAW CTRL input turned on, I do not see why any MIDI data should be sent to a software instrument, from a input device that is not connected to the software synth. Any MIDI data that originates from the DAW CTRL (if that is where it is coming from) should stay in the DAW CTRL path.
That is all that I have discovered.
Hope this helps.
Staque