I have:

<set attributeName="visibility" attributeType="CSS" to="visible" begin="5s" fill="freeze"/>
<set attributeName="visibility" attributeType="CSS" to="hidden" begin="10s" fill="freeze"/>

I want the loop to perform these instructions.

Rather than toggling back and forth between two different static set elements, you can use a single animate that switch between hidden and visible indefinitely.

Then you also don't need to worry about wiring up the begin timing with the end event of another named animation

<!-- begin snippet: js hide: false --> <!-- language: lang-html -->
<svg xmlns="http://www.w3.org/2000/svg">
  <circle fill="red" cx="50%" cy="50%" r="30" stroke="black">
    <animate attributeType="CSS"
             attributeName="visibility"
             from="visible" 
             to="hidden"
             dur="1s"
             repeatCount="indefinite"/>
  </circle>
</svg>
<!-- end snippet -->