As per the article https://support.apple.com/en-in/guide/photos/pht3bfab2f96/4.0/mac/10.14
When you delete photos and videos from your library, they’re placed in the Recently Deleted album, where they remain for the number of days shown and then are permanently deleted. You can restore items before that period of time. If you have iCloud Photos turned on, you can restore photos and videos from iCloud for 30 days before they’re removed from iCloud and your Mac. If you’re not using iCloud Photos, your deleted photos are removed from your Mac only. You can also manually delete photos from the Recently Deleted album to remove them immediately from your computer and iCloud.
The two devices are synced and signed in with same Apple ID and password on the same network and iCloud photo library is turned as on both https://support.apple.com/en-in/HT204264
And preferences is set up https://support.apple.com/en-in/guide/photos/pht5156cc968/4.0/mac/10.14
So , if you delete photos from any device it will be deleted from the other , even you sign in with Apple ID and password at www.icloud.com see the article https://support.apple.com/en-in/guide/icloud/mm08b49040b5/icloudand delete photos from iCloud.com
It will be deleted from all devices connected ( it could be your iPhone ) see this https://support.apple.com/en-in/HT205856