If your Mac is using iCloud Photos, and you delete photos in the system Photos Library (the one that syncs with iCloud), any deletion of a photo there is going to be taken as a request to delete the photo everywhere.
You can go into Photos > Settings… and select Optimize Mac Storage.

The other option would be to carefully turn off iCloud Photos on one device (your Mac) only. After that, no photos would automatically sync from your iPhone to your Mac, or vice versa. (There would still be some less convenient manual ways to transfer photos.)
How to turn off iCloud Photos - Apple Support