Not quite sure what’s happening here; what’s out of memory where…
If you are already out of storage on the iPhone, consider returning the iPhone for one with capacity adequate for your needs. If your iPhone has inadequate storage, expect to be managing that storage as iOS and apps all increase in size, and as usage increases. (It’s rare for storage usage requirements to decrease.) If you purchased this iPhone from Apple, you have 14 days to return for a refund. Other vendors’ refund policies can vary.
If you deleted an app and want to install it again, you can re-download the app from the App Store at your convenience. Open the Spp Store and look in your previous purchases list.
If you want to re-set and re-load the new iPhone and restore using the iCloud backup of the old iPhone, that will work and will revert the current contents to whatever was in the backup.
Restore your iPhone, iPad, or iPod to factory settings - Apple Support
Restore your iPhone, iPad, or iPod touch from a backup - Apple Support
Temporarily increasing iCloud storage (substantially) is also cheap and easy, and helps avoid the chance of data loss if you end up with no backups of anything…
iCloud storage plans and pricing - Apple Support
Manage your iCloud storage - Apple Support