Because the Ryzen 9 3900x is not 8 cores/16 threads, but 12 cores/24 threads. That's a 50% increase.
Now the 9900k is beating the 3900x not because it's faster. The games that are out now don't that many threads at all (and you can prove that by seeing how much difference there is between say, the 8700k and the i9 9900k. It's a small margin that proves that the extra cores aren't used that much) and because of that the cores which are singularly faster perform better, hence why the 9900k performs a little better.
And the counter argument with the fx 8350 is stupid if you ask me. It used a trash architecture, had shitty ipc (compared to Ryzen's and Core ix's which are the same now) and didn't truly have 8 cores, it's like an i7 2600k but that is half its speed due to the inferior ipc