iOS does backup your photos as part of its normal backup process, unless you enable iCloud Photo Library, in which case:
Photo Library is backed up separately as part of iCloud Photo Library.
Through the normal backup process (iCloud Photo Library disabled), your photos are backed up at most once every 24 hours along with the rest of your data, when your iPhone is on Wi-Fi, charged, and locked. Those photos can only be recovered by restoring your iPhone from your iCloud backup.
With iCloud Photo Library enabled, your photos get uploaded to iCloud every time you’re on Wi-Fi. This is a syncing process rather than a “backup” per se. However in the event that you lose your iPhone you will still be able to recover your photos from iCloud (even without restoring your new iPhone from backup). Therefore this option acts as a backup for your photos.
This distinction is a bit of a technicality, but the important part is you can consider your photos backed up to iCloud, no matter which option you choose. Since there is no need to backup your photos to iCloud twice, iOS only does one or the other.
What you’re seeing in that second screen is your photos being uploaded to your iCloud Photo Library specifically. It’s a different/separate method from the regular backup, which is why the photos need to be uploaded again. It doesn’t mean your photos never got backed up before.
If you have multiple Apple devices, I would advise you to keep using iCloud Photo Library, since that presents many advantages beyond a simple backup: quicker backup of your photos, synchronizing photos across devices, saving storage on your iPhone, allowing you to bring all your photos onto a new device, etc.