Are devices supposed to automatically be removed from iCloud when all content and settings are erased?
In a word, no.

Simply erasing a phone does not remove it from your list of devices in iCloud, nor does removing it from "Find My."

You have to go into iCloud and purposefully remove it from the list of "my devices" to indicate that you no longer own this device.

Just because you erase a device does not mean you no longer own it. Especially as erasing a device is often a valid troubleshooting step in finding problems with an iOS device.