The problem predates Mojave, and Catalina doesn’t improve on it.
That’s especially the case if you close a window in a browser that had a video or audio player in it, and then press the Play/Pause button. In my experience and that of many people who post about it, the last music player isn’t always tracked well. You could be in iTunes and use the keyboard to pause playback, then switch to YouTube in a browser, press play, and the keyboard would help you play and pause there, too. Then Apple broadened that to include anything with a music player. At one point in macOS history, if you had a Play/Pause button on your keyboard, it kept “focus” on whatever the last music app you used was.