When you are dealing with optional / repeating sections, their commands “bubble up” the dom tree of other sections they are contained in.
So if you have a section bound to a root node, and inside that you have an optional section, the section bound to the root node will receive the bubbled commands from the optional section.
To fix this, you have to place the optional/repeating section inside another container section. This can be a parent node, or if one is not available, a sibling node.