Two pieces do the heavy lifting: request routing and caching. When a user requests a file, the CDN uses DNS or anycast routing to send them to the closest healthy edge server, usually measured by network distance rather than raw geography.
On the first request for a file, the edge server does not have it yet. This is a cache miss. The edge fetches the file from your origin, sends it to the user, and stores a copy. Every later request for that file from that region is a cache hit, served directly from the edge with no trip back to origin.
How long a file stays cached is controlled by HTTP headers, mainly Cache-Control and the file's TTL (time to live). A logo with a one year TTL almost never hits your origin again. When you ship a new version, you either change the filename or send a purge command that tells edge servers to drop the old copy.
CDNs were built for static content like images, CSS, JavaScript, fonts, and video segments. Modern ones also do more: terminating TLS, compressing responses, blocking DDoS attacks, and running code at the edge with platforms like Cloudflare Workers or AWS Lambda@Edge.