Because order of function paramerer evaluaton is unspecified and modifying one value twice between sequence points is undefined behavior.
In your case std::cout << add(result) << add(result); is calculated first.
Then it transformed into std::cout << add(result) << 1; → std::cout << 2 << 1;
Your code might output "11" and this will be completely valid because of undefined behavior of your code.
To be fair, two function calls to add() are, using C++11 wording, "indeterminately sequenced" (C++98 similar), so the output can only be 12 or 21. The behavior is not undefined, merely unspecified which of the two possibilities take place.
Oh, yes: the program must behave as if the CPU instructions that constitute different function calls were not interleaved, even if the functions were inlined
However I do not see anything preventing "22" to be outputted:
calculate right hand side function and store variable in temporary variable of return type of the function (store reference to result)
do the same for left function.
Pass arguments (copy valye references are pointing at).
@MiiNiPaa you are right, I overlooked the fact that the function here returns a reference.
You can certainly have the case where both functions are complete (result == 2) before any of operator<<'s int parameters are initialized from their arguments, so 22 is another allowed result.