I have read this at the Science.com, and it’s in the second line of the last paragraph.
A bow and arrow or an atlatl allows users to attack prey—and enemies—from a safer
distance than does an ordinary spear.
I would have put it this way: A bow and arrow or an atlatl allows users to attack prey—and enemies—from a safer distance than an ordinary spear does.
So here are my questions:
Are both of the two sentences right?
When can I put the verb ahead of the noun? When is it a necessity?
It is a particular property of the pro-verb do (and also have, when it is a pro-verb, and be).
When one of these auxiliaries is used to stand for a verb phrase which has just been mentioned, after a conjunction like than or as, the verb may precede the subject:
He is going home now, as am I.
I want this to end, as do they.
The inversion is not compulsory, and tends to be associated with more formal or literary language than the uninverted form (your no. 2):
He is going home now, as I am.
There is a parallel with So used to mean also:
So does he!
but in this case, the inversion is compulsory, as without it the meaning will change:
So he does.
means either and therefore he does (whatever) or I am surprised or appreciative that he does (whatever) depending on the intonation; but it has no sense of as well.