How to prevent plugins from being uninstalled

Yes, you can use the same filter, just remove the delete key of the $actions array. If you want to remove the “delete” link for the plugin “myplugin”, you’d go for something like this:

add_filter("plugin_action_links", function($actions, $plugin_file, $plugin_data, $context) {
    if($plugin_file == "myplugin/myplugin.php") {
        unset($actions["delete"]);
    }
    return $actions;
}, 10, 4);

Obviously, you cannot put this into the plugin itself, since it will have been deactivated or the delete link will not show up (link to deactivate the plugin will be in its place). Also, be aware that this will only remove the link, it will not stop a determined user with the appropriate privileges from sending that request manually.