Why does a on Comment edit page submit the page?

This is happening because the entire comment edit page is inside a <form> element, and the <button> element submits any form that it belongs to. This is the normal behaviour of buttons in HTML.

If you don’t want a button to act as a submit button, you need to set the type attribute to button:

<button class="ed_button button button-small" onclick="copy_civicrm_subject_code()" type="button">
  Copy
</button>

The default type attribute for a button is submit, which is why it behaves that way unless you set it to button.