This works because factorial(4) is 4×3×2×1 = 4×(3×2×1) = 4×factorial(3).
In order for a recursion to work there has to be a base case that the procedure can handle without calling itself; in this case we build in that factorial(1)=1. Otherwise the procedure would keep calling itself forever and never return.
It's important to understand that variables in a recursive procedure, such as number in this example, don't belong to the procedure itself; they belong to an invocation (a call) of the procedure. The way computers work is that inside the computer are a lot of really tiny little people. When you ask for factorial(4), you hire Francine, a factorial expert, and give her a 4 to put in her number pocket. Francine hires other little people for other procedure calls; for example, she hires Edgar to compute the = test, and Isabel for the if, and so on. But what's important for our story is that she hires Fred to compute factorial(3); she gives Fred a 3 to put in hisnumber pocket. He hires a bunch of other little people, including Fanny to compute factorial(2); she hires Ferdinand to compute factorial(1). Ferdinand just hands 1 back to Fanny. Fanny, who still has 2 in her pocket, multiplies Ferdinand's 1 by her 2 and gets 2, which she reports to Fred, who multiplies her 2 by the 3 in his pocket to get 6, which he reports to Francine. She still has 4 in her pocket, so she can multiply Fred's 6 by her 4 to get 24, which she puts in a speech balloon to show you, because you hired her back at the beginning of this paragraph.
Recursion is especially important for things like fractal trees, where you have to make more than one recursive call (one for each branch of the tree). You can't do that just by writing loops -- or I should say, you can, but it's a real pain.
Oh I see the problem. You're answering the question, how can the procedure refer to itself? And, sure, by using the same number it's in.
I was answering a different question, about the procedure's local variables (including inputs). Those variables can't belong to one of the numbered slots; they have to belong to a particular invocation of that procedure.