If you turned on iCloud Photo Library on your iPhone, and then deleted them from the iPhone once they were showing in the Photos album in iCloud.com, then you deleted them from that Library. iCloud Photo Library is a sharing service, not an archival one, so the iPhone is using the same Library as iCloud, and any action you take on that library from either of those places is going to be reflected across the board.
You should have a Recently Deleted album on your iPhone. Go there and recover the photos.
You can turn on Optimization under Settings>Photos & Camera, but if you cannot delete the photos off of your phone or they will be deleted from the library.
iCloud Photo Library FAQ - Apple Support
iCloud Photo Library Help - Apple Support
If you want to be able to delete photos off of your phone, you would need to turn off iCloud Photo Library, and import those photos to your computer. But first you would need to download the photos in the iCloud Photo Library to your computer.
Best of luck,
GB