Instead of using the firstChild property like this:
Use this other:
In your HTML, the blanks you leave to format your HTML view are considered text nodes. So when you do
lista1.firstChild , it is returning the nodes that are spaces, enter, tabulations, etc.
Therefore, the first click you do, removes a text node that contains the character of the enter key and other spaces, and adds them to the list2 node. The second click finds the li node within list and adds it to list2 . The third click of new text node ( spaces ), and so on ...
To verify that, you can leave firstChild as is and change your HTML so that it does not have spaces:
<input type="button" value="Cambiar posicion" onClick="cambiarPosicion()">
Anyway, this is horrible for everyone, but it serves to check.
This is documented in English here