See a thread Cloud and Hard Drive - Apple Community
Keep your Mac up to date - Apple Support
When an iPhone and Mac are signed with same Apple ID and password on the same network and photos box is turned as on the photos will sync , if photos are deleted from iCloud.com they will get deleted from iPhone and Mac .
In Mac set up photo library and its preferences see the articles
Set up and use iCloud Photos - Apple Supportsupport.apple.com › en-in
Change preferences in Photos on Mac - Apple Supportsupport.apple.com › en-in › guide › photos › mac
System Photo Library overview for Photos on Mac - Apple ...support.apple.com › guide › photos › mac
When photos are hundred percent synced , sign out Apple ID from an iPhone .
Sign out of iCloud on your iPhone, iPad, iPod touch, Apple TV ...support.apple.com › en-in
And sign in with new Apple ID and password that is created with you in the past .
Sign in with your Apple ID - Apple Supportsupport.apple.com › en-in
Then share photos from Mac to iPhone .
Subscribe to shared albums in Photos on Mac - Apple Supportsupport.apple.com › en-in › guide › photos › mac
The Apple ID and password are totally different in iphone and mac if you delete photos from mac or icloud the photos will be not deleted from iPhone .
The invitation has to be accepted to receive photos ( has to be subscribed ).
Share iPhone photos with Shared Albums in iCloud - Apple ...support.apple.com › en-in › guide › iphone › ios
Your previous old photos are in primary icloud account and are not lost as they are saved on Mac .
Hence photos are in iPhone as well in Mac - this method was according to your original title - How do I delete photos from my iCloud account but leave them on my iMac and iPhone .