I assume you are using iCloud Photo Library. If so, see these articles:
Get help with your iCloud Photo Library - Apple Support
iCloud Photo Library FAQ - Apple Support
especially the section:
How do I delete photos and videos from a device using iCloud Photo Library?
If you want to remove photos and videos from all your iOS devices, Mac, and iCloud.com, you can delete them in the Photos app.
When you delete a photo or video from your Photos app, it will also delete from your iCloud Photo Library and iCloud storage. You can recover your photos and videos from the Recently Deleted album for 30 days.
How do I remove all iCloud Photo Library content from iCloud and my devices?
To turn off your iCloud Photo Library, follow these steps:
- On your iPhone, iPad, or iPod touch, go to Settings > iCloud > Storage > Manage Storage > iCloud Photo Library, then select Disable and Delete.
- On your Mac, go to Apple menu > System Preferences > iCloud. Click Manage, select Photo Library, then select Disable and delete.
Photos and videos will be stored in your account for 30 days. To download your photos and videos on your iOS device, go to Settings > iCloud > Photos and select Download and Keep Originals. On your Mac, open Photos, choose Photos > Preferences, then select Download Originals to this Mac. You can also select the photos and videos that you want to download from iCloud.com.
Can I use iCloud Photo Library to save space on my device?
iCloud Photo Library automatically keeps all your photos and videos in the original, high-resolution version. Follow these steps to choose how you store your photos and videos on your device:
- On your iPhone, iPad, or iPod touch, tap Settings > iCloud > Photos or Settings > Photos & Camera, then select a storage setting.
- On your Mac, click Photos > Preferences > iCloud, then select a storage setting.
If you turn on Optimize [device] Storage, iCloud Photo Library will automatically manage the size of your library on your device, so you can make the most of your device's storage and access more photos than ever. All of your original, full-resolution photos and videos are stored in iCloud while device-size versions are kept on your device. You can download the original photos and videos over Wi-Fi or cellular when you need them.
If you turn on Download Originals, iCloud Photo Library will keep your original, full-resolution photos and videos in iCloud and on your device. Download Originals is the default setting for iOS devices with the free 5 GB storage plan and for all Mac devices.
If you keep iCloud Photo Library on, then I believe if you delete the photo on one of your devices, it will be deleted on all of your devices (and iCloud).
This may help with the iCloud Security Code issue:
If you enter your iCloud Security Code incorrectly too many times - Apple Support