iCloud is designed as a synchronization service, and as a place to store iPhone/iPad backups. With a lot of the stuff that you're synchronizing, you need to have it stored both in iCloud storage – and also locally, on each Mac, iPad, or iPhone synchronized through that iCloud (Apple ID) account.
That said,
- On versions of macOS prior to Sonoma, you can right-click on a file in iCloud Drive which has a local copy (these are the files without cloud download icons) and "Remove Download". That removes the local copy of the file. To use the file again, you must download it again.
- In Sonoma, Apple changed things so that this feature is disabled unless you enable "Optimize Mac Storage". (Based upon the screen shot that FoxFifth posted, looks like a second "switch similar to the Photos / iCloud Photos one.)
- On the iPhone or iPad, you can "Remove Download" on iCloud Drive files using the Files app (see linked article).
Delete files or recover deleted files in the Files app on your iPhone or iPad - Apple Support
https://eclecticlight.co/2023/09/26/apple-has-released-macos-14-sonoma/
With iCloud Photos, you cannot manually delete a photo from one device, and have the original remain safely in iCloud or on your other devices. Deleting a photo or video in one place is a request to delete it everywhere.
You can use the "Optimize Mac Storage" switch in Photos > Settings… > iCloud to let the system substitute low-quality local copies for full-size local copies when you are running low on space. The idea is that you can re-download full-size copies on demand. Note that even if you turn on "Optimize Mac Storage", the system will still store a lot of photo and video files on your Mac.