Will 40-635 tyres fit on a 21-622 rim?
The diameter measurement in an ETRTO specification is the rim bead set diameter in millimeters. You must use a tire with the same bead diameter as the rim of it will not fit.
If you have a 622 rim you must use a 622 tire. A larger diameter tire will simply blow off the rim when you try to inflate the tube.
With regards to width, there is a maximum tire width depending on the width of the rims but the frame clearance is usually the limiting factor. See What is the maximum or minimum tire width I can fit on my bicycle.