If this build is for gaming, buy the Ryzen 7 7800X3D even though it costs more. The Core Ultra 7 265K being cheaper and having more cores doesn't matter if the games you're actually playing run worse on it.
The price doesn't tell the real story
Used, the Core Ultra 7 265K runs $23.01 less than the 7800X3D on ChipFlip's tracked listings, and on paper it looks competitive: 20 threads against the 7800X3D's 16, a genuinely capable multi-threaded chip. But Newegg Insider's comparison and independent testing both put the 7800X3D roughly 14 to 22% faster in gaming on average, driven entirely by its 96MB of 3D V-Cache. That cache slashes cache-miss penalties in game engines in a way raw core count and clock speed can't fully replace.
Why more cores didn't win this one
Gaming performance leans hard on cache and single-thread latency, not total thread count. The 265K's extra cores are a real advantage for multi-threaded productivity work, and a non-factor for the specific thing this comparison is really about.
Where the 265K wins outright
Mixed-use builds: heavy multitasking, content creation, compiling, alongside gaming. There the extra threads earn their keep in a way they simply can't in a pure gaming benchmark.
The takeaway
Gaming-first build: the 7800X3D's cache advantage is worth the extra $23.01, it isn't close. Mixed productivity-and-gaming build: the 265K's extra threads make it the more balanced pick, even if it gives up some frames along the way. Know which one you're really building before the price tag decides for you.