Look up how HLS (HTTP Live Streaming) works. They just need to generate a personalized playlist for each person which points at things already hosted on CDN, and insert the ads where they want in the literal text file that your video player reads from to serve you the video.
I don’t know much about it, but it looks like there’s specific tags designed for dynamic ad insertion. Idk if YouTube plans to use them in this case though, if they want it to be undetectable to the client.
I’ll say that if the really talented people are signing on to this, that could be noticeable. I know Amazon tends to just churn through devs every year, but actually good software engineers are surprisingly hard to find.