Is a machine with more cores or threads always better?
Usually, yes.
But it depends, and mainly on architecture, frequency and so on.
Some cheap second-hand server machines have plenty of cores and threads, but because of architecture, frequency and other factors, each core is much worse than a core on a mainstream machine today, and if the instruction set is not advanced, the speed is unsatisfactory too.
For example, the E5 2660 v2, with 10 cores and 20 threads, does not support advanced instruction sets such as avx2 and bmi2. Even with all 20 threads running, it is not as good as 3 or 4 cores of a 7950x running with bmi2.
Hardware determines the engine's search speed, and the final way to evaluate hardware for an engine is nps; see What is NPS (the "K value")? Does it represent playing strength?.
For how speed affects strength in balanced positions, see What is the draw rate of top Xiangqi engines today?.
