Music on macOS is really weird architecturally. Parts are native, parts are WebViews, and I wouldn't be surprised if there's even still some bits of code leftover from the days Music/iTunes was still known as SoundJam MP.
They're likely doing something funky to implement its shortcuts because the standard way wouldn't work everywhere in the app.
Ironically, at this point the cleanest implementation of Apple Music might actually be the Windows version, which as far as I can tell is a fresh codebase written exclusively in WinUI/WinAppSDK. Many hoped that the transition from iTunes → Music.app would turn out to be a blank-slate AppKit rewrite on macOS but that's not what we got.