The backplate of most of the smaller 22mm multirotor motors is normally between 1.5 and 2.0mm thick. You need to add to this the thickness of the frame arm to get the proper screw length to hold the motors in place.
Typically there is about 1.5 to 2.0mm of space between the inside surface of the motor backplate and the motor windings. However, under 1 or 2 holes, the motor leads themselves are typically just 0.5mm above the inside surface and sometimes actually touching the inner surface of the motor. Ideally, you want the screws to be such a length that they go through the quad frame arm, through the entire backplate of the motor, and only stick into the motor about ½ of a thread. This gets you full screw engagement without having the screws stick far enough inside the motor to cause any harm.
Most quad frames have arms that are 3.0mm thick, and most motors come with 5mm long mounting screws. For a motor that has a backplate which is 2.0mm thick, the tip of the screw ends up being flush with the inner surface of the motor backplate. With motors that have a backplate that is 1.5mm thick, the screw will stick up into the motor 0.5mm once installed. The washers that come with the motors are typically between 0.4 and 0.6mm thick, so if one of these is used on the thinner motor backplates, the tip of the screw is just barely above the inner surface of the motor backplate, sticking up only 0.1 to 0.2mm.
When you switch to a frame that has 4mm thick arms, you need to purchase 6mm long screws to get full engagement of the threads in the motor backplate. If you try and use a 5mm long screw, you will only get 1.0 to 1.5 threads of screw engagement, and this puts too much stress on the threads and will strip them out. The standard metric thread on the screws is an M3 x 0.5mm thread. This means that on a backplate that is 2mm thick, you only have a maximum of 4 threads in the motor. Since most of the holes have a slight countersink on them, this only leaves about 3.5 threads on most motors. To prevent stripped screws, you need to use all the threads that are available, but you also need to make sure that the screws do not stick up too far into the motor. If the screws do stick into the motor too far, then you have to put a washer under the screw head to take up the slack. In some cases, you may even need to use 2 washers under each screw to keep the screw length correct.
For anyone that is serious about flying FPV quads, I highly recommend purchasing a box of 5mm and 6mm M3 x 0.5mm socket head screws, along with a box of 3mm flat washers. These screws come 100 to a box, which will last a lifetime, but only cost a few dollars per box. McMaster-Carr is the best place to purchase them from. Their website address is www.mcmaster.com
A 100-piece box of the 5mm long screws costs $8.21 and the part number is 91290A110. https://www.mcmaster.com/#91290a110/=1792n1l
A 100-piece box of the 6mm long screws costs $8.02, and the part number is 91290A111. https://www.mcmaster.com/#91290a111/=1792ngw
A 100-piece bag of the M3 flat washers costs $1.62, and the part number is 93475A210. https://www.mcmaster.com/#93475a210/=1792og8
This would get you everything you need to properly mount your motors and adjust the length of the screws as needed with the washers to get a perfect fit every time.
Hopefully that helps!