Because iCloud storage is stored in the cloud, on Apple's servers. It has nothing to do (at least directly) with your phone's storage. Device storage is the storage available on your iPhone, iPad, Mac, or other Apple device. iCloud storage keeps your photos, files, notes, and more up to date and available on all your devices.
I say this directly, because there are some indirect things you can do: you can download unused data and applications to iCloud and thus free up space on your phone, but having, for example, 2 TB of iCloud storage doesn't magically give you 2 TB of storage on your phone itself. To optimize iCloud storage, you can manage your documents, movies and other data locally by transferring these files between your PC and iPhone. For example, if your iPhone says that the storage is full but it isn't, you don't need to delete files or buy more iCloud storage space; you should still be able to take photos and receive text messages and other content. On the other hand, if your iCloud storage is almost full, the notifications don't go away, learn how to manage your iCloud storage.
You can also back up all your data to iCloud and then delete the backup and the photos, videos and songs from your iPhone. The more storage space your device has, the more music, apps, photos, and other content you can store on that device. You can delete unnecessary emails with large attachments to quickly get rid of several gigabytes and clear iCloud storage. Here's how to check the amount of storage on the device you've used and, if necessary, how to optimize and manage the storage space.
Photos are likely to be the main culprits, so start there and make sure that the “Optimize iPhone storage” option is enabled. iCloud storage allows you to securely store all your photos, contacts, documents, text messages and more and access them from any iOS device with the same Apple ID. If you find an alternative way to store your photos, videos and backups and back up your data locally, you can manage your iCloud storage more efficiently and stop worrying about your iCloud storage being full. If you ever see the message “storage almost full” or “iCloud storage almost full”, check your storage first.