The base M4 does not outperform the M2 Ultra in NPU function, though if you're not familiar with how TOPS ratings are determined it's easy to misunderstand. The short of it is you need to know what operation the TOPS rating is measuring when comparing.
M1 - M3 Neural Engines were measured using FP16 operations, whereas the M4 chips (and A17 and A18) are measured using INT8 operations. FP16 operations handle about twice as much data per operation than INT8. They're not entirely interchangeable but 20 FP16 operations would equalize out to about 40 INT8 operations.
The M2 Ultra is rated at 31.6 TOPS in FP16, which would be equate to roughly 62-64 TOPS in INT8. The M4 is rated at 38 TOPS in INT8.
Similar confusion occurred with the M3. Apple measured the M3 Neural Engine with FP16 but the corresponding A17 Neural Engine was measured with INT8 for whatever reason, thus making it seem that the A17 had a faster NPU than the M3 when they were essentially the same. The M4 looks like a huge leap over the M3 on paper because of the TOPS figure, but it's actually only about 5-10% faster. The M2 was actually the biggest boost to NPU performance in the four generations of M chip, about 40% faster than the M1.
For the record this is not Apple being sneaky, they made the change because AMD, Intel, and other companies coming out with NPU hardware are measuring in INT8 and it's become something of the de-facto standard benchmark for NPUs. Apple, with good reason, didn't want their NPUs specs to look worse because of a reason like that.