Is your trackpad an Apple Magic Trackpad, and if so, which model? If you see the same behavior with then internal trackpad, then that is likely not relevant.
See if the problem is present when you boot in safe mode. That process performs some system cleanup and clears caches, and also disables 3rd party extensions that may cause problems.
Start up your Mac in safe mode - Apple Support
If that does not correct the issue, test in a new user account. A newly-created user account will have all settings at default, and if the issue does not occur in that new account then it provides guidance on what may need to be changed to correct the issue.
Add a user or group on Mac - Apple Support
Once the testing is complete, the new account can easily be deleted.
Delete a user or group on Mac – Apple Support
Those steps will help to isolate the problem.
It might help to download and run EtreCheck, written by a long-time forum member. The free version is fine. Post the full report using the Additional Text button. No personal information is revealed.

Personally, I cannot replicate the issue that you describe. I have the Show Desktop trackpad gesture enabled on my M4 Pro MBP (currently in clamshell mode connected to a 5K:2K display, with a Magic Trackpad connected), running macOS 27 Golden Gate.

Here is before and after the 'Spread with thumb and three fingers' gesture:


It is possible that it's problem specific to your M5 Mac model, but more likely that it's something installed on your Mac (extension, etc.) causing the issue. If the issue remains in safe mode and a new user, that makes a bona fide bug more likely (model specific bugs happen, but they're more rare). Bugs can be reported to Apple here:
Feedback - macOS - Apple