iCloud is not a backup service. iCloud is a synchronization service. It's designed to keep things synchronized across Apple devices. If you delete a synchronized item on any Apple device then it will be deleted from all sycnchronized devices and from iCloud. If you delete it directly in iCloud (on the web, say) then it will be deleted from all your devices. That's how it's designed to work. You can't stop it working like that.
If you haven't got separate backups of your important files and photos on a separate hard disk then you are at risk of losing them - if you haven't already. Have a search for "3,2,1, backup system" once you've checked the links below.
These might help.
Back up iPhone – Apple Support (UK)
What does iCloud back up? – Apple Support (UK)
Back up your Mac with Time Machine – Apple Support (UK)
Introduction to iCloud – Apple Support (UK)