what doesdo?Code:diag(A), diag(diag(B))

I know that the first part takes the diagonal of matrix A and displays it as a vector, and the second part takes the result from the first part and does the same process again. But why for the second part it seems to criss cross the results?