You have multiple problems but most of them stem from lines 10 and 16.
At line 16 you have detected that you have an end condition but rather than return an end condition flag you return the same value as you leaf condition at line 6. If your end condition is 2 you should return 2 so in fact you should probably always return a rather than conditionally returning it only when it is not 2.
Then at line 10 you do not check the return condition of one call to common
before making the next one, so even if the first call returned the end condition you still carry on with recursion in the second call. It probably wants to change to something like
a = common(temp->left,c,d);
if (a != 2)
{
a += common(temp->right,c,d);
}
There is a problem with that, if the first call returns 1 and the second call returns 2 the value of a is 3 which has no defined meaning in you value scheme
0 = leaf reach with no match
1 = match found in branch
2 = end condition reached
So you will need to modify it to prevent a getting or at least returning the value 3