I've got this too. Have had a long time now.
Anything played on the iPhone, has absolutely no effect on exactly the same playlist (based on play count), on iMac, iPad and Apple TV.
I was led to understand, from posts by other users elsewhere, that the latest 17.2 update had fixed this (congratulations to them), but not for me.
I've now also noticed that, despite having the "use mobile data for downloads, streaming, updating your library and loading artwork," checked (green), when I look at 'history' on the iMac, the only 'registered' music, is the track I set going before leaving the house. And nothing played since getting back in and before taking the headphones off either.
Last.fm shows all the tracks played during the day, but not Music on the iMac (which I thought was the central 'hub'). So at least I know I'm not going crazy.
This is intensely irritating. And goes against the 'Sync Library (also green), saying "Your purchased music, content you add from Apple Music or import to iTunes (why iTunes?), and changes you make to your library will sync across all your devices." Plainly and demonstrably, not true.