It seems like it works, but actualy it doesn't.
*a points to address on the stack.
When you print **a, what is acutaly printed is the content of certain address on the stack. (The address that contained 5 when you call the function f).
However, because the stack doesn't change much according to your code, the value 5 is still written on the certain address so the value 5 is printed. If you would call to other function and then print **a you will probably get different value.