Collapsible accordion spreads and collapse instantly

I have a collapsible accordion placed inside a form. Pressing the button to spread, the accordion spreads and collapse back instantly. If I don’t put it in the form, it works fine for me. This is the simplified code: index.html:

<html>
    <head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="estilos.css">
    </head>
    <body>
    
    <form  method="post" id="platos">
    
    <button class="accordion">Section 1</button>
    <div class="panel">
    <p>Lorem ipsum...</p>
    </div>

    <button class="accordion">Section 2</button>
    <div class="panel">
    <p>Lorem ipsum...</p>
    </div>

    <button class="accordion">Section 3</button>
    <div class="panel">
    <p>Lorem ipsum...</p>
    </div> 
    
    </form>
    
    <script src="collapsible.js"></script>
    
    </body>
</html>

collapsible.js

var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
  acc[i].addEventListener("click", function() {
    this.classList.toggle("active");
    var panel = this.nextElementSibling;
    if (panel.style.display === "block") {
      panel.style.display = "none";
    } else {
      panel.style.display = "block";
    }
  });
}

Answer

For each button inside the form tag, specify type="button", and these buttons will stop working as a submit:

<button type="button" class="accordion">Section</button>