That is the correct behavior. If a custom JS script is set to run on the frontend, then it should also run when editing the page with the Elementor page builder.
Nevertheless, you can specify inside you JS custom code that, if the Elementor page builder is active on the page, then it shouldn’t add the megamenu. You can do that by adding the following JS code:
if ( $('body.elementor-editor-active').length > 0 ) {
return true;
}
right after the jQuery(document).ready(function($){
line.
But this is not an issue related to the Simple Custom CSS & JS plugin. If you need more help about the megamenu script in the Elementor page builder editor, please consider getting some help on the stackoverflow.com website.