Drupal.behaviors js code executes mutiple times (depends on active modules)
once() may work in many cases. I've also used a flag like:

(function ($, Drupal) {
  let flag = false;

  Drupal.behaviors.my_module = {
    attach: function (context, settings) {
      if (flag === false) {
        flag = true;
        console.log('This should only display one time.');
      }
    }
  };

})(jQuery, Drupal);


Please note that I only wrote this in this comment box from memory and didn't actually test this code.

Also FYI, the Drupal.behaviors is correctly running many times, since it is supposed to update every time some kind of state changes that would require it to update (like an AJAX call). So you do have to take extra steps on your side to ensure that certain code only runs once.