Crackpot research paper in mathematics
Here are the basic mechanisms that I know of, having only limited experience on an editorial board.
The first is a classic desk rejection.  This is where the editor who makes the initial assessment, just says no, without asking for referees.  This has to happen, or one gets flooded with AI generated nonsense as a joke.
Some journals insist that you list a few potential referees.  I believe that one of the reasons they do this is to see if you have interactions (even just closely reading their papers) with mathematicians.  If the author of a number theory paper list as potential referees three Fields medalists from three different areas of mathematics, probably they have no idea what they are doing.  Makes a desk reject easier.
The second is the editor asks for a quick opinion from a mathematician in vaguely the correct area, asking if the paper is worth refereeing.  You can tell if you get this type of rejection sometimes as the editor says after a few weeks something like &quot;the feedback I have gotten are that this is out of scope for our journal.&quot; So I have heard.  From a friend.
Finally there is just sending it to one or more reviewers.  If the editor needs one referee, asks four in succession and they all say no, then the editor is likely to reject the paper.
There are problems with these methods.  Some innovative work is hard to classify, and a paper gets rejected because the editor asks all the wrong people.  I had a paper go to a topic editor, go out for review, then get assigned to another topic editor, out for several reviews.  It finally landed on the correct reviewer, but this could easily have gotten rejected.