Hey there, RichardRogersavatar,
Thanks so much for using Apple Support Communities. We can definitely help you get your Apple Music library sorted out and looking good again!
We want to start by having you try disabling the sync music feature on any device that you use Apple Music with. It's possible that those songs are syncing back from another device that is signed in to your Apple Music account. Although we would expect those changes to sync across all of your devices, it's possible that that is not the case right now and we hope that by toggling that feature off on all of your devices, it may help resolve the issue.
This article has the steps to toggle that off on any devices you may be using: Use Sync Library to access your music library across your devices - Apple Support
After you do that, go ahead and delete those songs again and see if they come back on the iMac. If they don't, try toggling the sync feature back on on your other devices and see if that may have done the trick.
We hope that this information is helpful.
Have a great day!