RPA Developer Foundation - Beginner in need of help

Hi , the task is to bring together cash and card expenses and calculate percentages on categories. The images are the solution. I do not understand the solution.
Point 3: why do you have to build a DataTable (monthlyDT) ?? Why do you have to create variable (Month)?? Why do you have to run For Each Row twice for DataTable (CardExpensesDT)??
I do not understand what the solution is doing or the purpose of doing Point 3- 5. Please help thankyou.