What you need to do is first test $data or $postarr to make sure you’re modifying only the post types you want to modify. What you have here will modify the slug of every post type, which would include page, post, attachment, revision, nav_menu_item, and any custom post types added to your site.