I'm sorry, but I can't reproduce this.
Besides, your "Before Editing" image does not match with the shapes I get from provided link. To me it looks like you have only loaded the original countries.json
to Mapbox, perhaps with a different name but still with the original content.
library(sf)
#> Linking to GEOS 3.11.2, GDAL 3.6.2, PROJ 9.2.0; sf_use_s2() is TRUE
library(mapview)
orig <- read_sf("https://github.com/CodingWith-Adam/geoJson-map-with-react-leaflet/raw/master/src/data/countries.json")
orig[orig$ADMIN == "Morocco",] |> mapview()
orig[orig$ADMIN == "Western Sahara",] |> mapview()
# after merging:
merged <- read_sf("countries.geojson")
merged[merged$ADMIN == "Morocco",] |> mapview()