IMO, the best way to understand some code is to trace through it using the debugger and watch the variables. or just use pen/paper. Draw out a simple list showing pointers etc, then trace through the code using the list.
Is this C or C++ code? If C++, it's not the best written.
To understand linked list code, consider a list as a collection of nodes - with the next element of a node pointing to the next node in sequence. The next element of the last node is nullptr to indicate that there are no following nodes.
To iterate the list, start at the first node (list), process its contents as required, then use the next element to get the next node. Continue until all nodes are processed.
To add a node to the end of the list, you first have to iterate the existing list to find the end. Then the next element of the last node of the existing list is then set to the new node to be added.