Let's try to visualise stack (yes, there is only one stack) for different stages of call foo(4):
before calling foo(4): caller-stack
within original call foo(4): stack=caller-stack, foo(4)
when foo(4) is within the first call to foo(2): caller-stack, foo(4), foo(2)
foo(4) within the first call to foo(2), where foo(2) has already called first foo(1): caller-stack, foo(4), foo(2), foo(1)
after returning from first foo(1): again caller-stack, foo(4), foo(2)
foo(4) within the first call to foo(2), where foo(2) has called second foo(1): caller-stack, foo(4), foo(2), foo(1)
after returning from second foo(1): again caller-stack, foo(4), foo(2)
after returning from first foo(2): caller-stack, foo(4)
foo(4) is within the second call to foo(2): caller-stack, foo(4), foo(2)
foo(4) within the second call to foo(2), where foo(2) has already called first foo(1): caller-stack, foo(4), foo(2), foo(1)
after returning from first foo(1): again caller-stack, foo(4), foo(2)
foo(4) within the second call to foo(2), where foo(2) has called second foo(1): caller-stack, foo(4), foo(2), foo(1)
after returning from second foo(1): again caller-stack, foo(4), foo(2)
after returning from second foo(2): caller-stack, foo(4)
after returning from foo(4): caller-stack
int a = n;