Rules in Apple Mail for desktop have never consistently worked. It's a problem that has been going on for many years and has never been directly addressed by Apple.
You will find that some parts of a multi-function rule work and parts don't. For example, the rule marks the message read, but won't move it to the appropriate mailbox. Seems like the moving to another mailbox step is the most common failure I've seen.
Also, if Apple Mail runs long enough (like over a day or two), it will seem to forget to check for new mail at all at some point.
Closing, force-quitting, or otherwise restarting mail will usually get rules and mail checking to work again (briefly), but it's a pain. Every morning, I have to "select all" mail in my inbox, then right click and "apply rules" manually.
This happens on every one of our iMacs and laptops (over 30), even on the new M1 iMacs.
And since Monterey, the feature where Mail learns and suggests a folder to put an email into when right clicked ("mail suggestions"), is also not working - at least not on the new M1s. I had an Apple support tech duplicate this on one of THEIR OWN iMacs, and they still just swept it under the rug.
So the temporary "Solution" to your issue (and most Apple Mail issues) is, completely close Apple Mail. And then start it again. And hope that someone at Apple will eventually fix the app.