In the beginning, $A$ is initialized as: $A = [1, 0, 0, ..., 0]$
The outer loop is running from $i = 1$ to $n$, where each iteration is basically calculating the coefficients for a new value of $n = i$
At the beginning of each outer loop iteration, the current array $A$ is copied to $B$
This means that $B[j]$ holds $\binom{i-1}{j}$ — the binomial coefficient values from the previous iteration and we are using these values for next.
We know that :
$$
\binom{i}{j} = \binom{i-1}{j-1} + \binom{i-1}{j}
$$
$B[j-1]$ is just $\binom{i-1}{j-1}$
and $B[j]$ is $\binom{i-1}{j}$
So, the inner loop is running from $j = 1$ to $n$, and updating $A[j]$ as:
$$
\boxed{A[j] = B[j - 1] + B[j]}
$$
Try for $n = 4$.
Initially:
$A = [1, 0, 0, 0, 0]$
After $i = 1$:
$A = [1, 1, 0, 0, 0]$
$A$ stores $\binom{1}{j}$
After $i = 2$:
$A = [1, 2, 1, 0, 0]$
$A$ stores $\binom{2}{j}$
After $i = 3$:
$A = [1, 3, 3, 1, 0]$
$A$ stores $\binom{3}{j}$
After $i = 4$:
$A = [1, 4, 6, 4, 1]$
$A$ stores $\binom{4}{j}$