You're correct. They are ensuring it by placing it in their terms for the use of their code/images on other sites. Nowhere in the GDPR does it say that every third party whose content may be placed on a site must themselves obtain consent. What exactly do you envision? That each page you load have 40 different consent dialogs show up?
On ingress the data could be deleted if it didn't correspond to a user that had given consent.
FB doesn't get to use the data unless it's consented by the end user.
It is distinctly not GDPR compliant for FB to claim that their TOS requires consent so it's not their problem. Feel free to read the discussion about co-controllers (called as joint controllers) and particularly the A29WG guidance.
For each external tracker, you will have to consent that use. By name. Per discussions you can find via google, even naming a well-defined class of 3rd party controllers is not enough; they have to be individually named.
This is the impact on adtech. See eg https://pagefair.com/blog/2018/granular-gdpr-consent/ . Or digiday, which is not exactly anti-adtech. https://digiday.com/media/gdpr-will-change-facebook-ad-targe... .
The fact that some page may have hundreds of co-controllers is immaterial, unless you envision "we don't want to" as a defense to the privacy regulators.
See even the IAB's (can't wait to hear how they don't support adtech either) consent dialogs http://advertisingconsent.eu/wp-content/uploads/2018/03/Tran...
page 16-18. And note the consent on page 16 is invalid; the GDPR is crystal clear that consent must disclose all co-controllers.