Yes, but it's a sort of a race condition between forks,
Correct. This is how the network reaches consensus and agrees on the contents of the blockchain.
at which point you measure which one is longer,
At the point where it becomes longer. Note that there is a possibility that one fork can become longer for a brief time, and then the other fork can catch up and become longer. This is why BOTH forks are stored by the node. The longer fork is the "valid" fork only so long as it remains longer. If the other fork ever extends longer, then the entire fork that used to be longer is abandoned (orphaned) and the new longer fork becomes the "valid" fork. This rarely happens more than 1 block deep, and extremely rarely happens more than a few blocks deep, but it is ALWAYS a possibility.
after the second block arrives in one of the forks?
Correct. Once a fork is longer, it is the valid chain so long as it remains longer.
How long ( or by how many blocks longer) one fork needs to be to win?
It simply needs to remain longer. So long as it is longer, it is the current "valid" chain. If it ever stops being longer, then it is abandoned and orphaned.
Note: All references to "longer" in terms of bitcoin blockchain actually mean "most total work" as determined by the difficulty. Under normal circumstances the chain with more blocks will be the one with "most total work", since any blocks at the same height should all have the same difficulty. However, there are attacks that can alter the difficulty, and if difficulty isn't taken into consideration properly, then it could be possible for an attacker to trick you into following a chain with many blocks at very low difficulty when the rest of the network is following a chain that has less blocks at a much higher difficulty.