This is not a glitch, just the way images render when non-native resolution (or non-integer scaling). For example. If you take a 16x16 resolution sprite, and scale it to 50%, then it is 8x8. But if the border was 1 pixel, what should be displayed. The pixel is technically 0.5 of a pixel, but the screen can either show 1 pixel or 0 pixel. So depending on the anti-aliasing and where the map is on the screen (because the map can also be at non-integer locations) you get to the situation where either a whole pixel is shown, or no pixel, or some interpolated sub-pixel (which shows as gray). This is just how pixels work.
To fix it, there are a few things to try. One, never use 1 pixel borders, and try to avoid obviously repeating patterns in the sprite. This will fix most of it, because it will be there no matter what, but if it were say a detailed grass sprite, you would never notice. You can make the border larger, like 2 or 3 pixels, but this will typically look bad from a design standpoint and is not recommended. Or you could draw the grid with drawing functions (manually using draw line, so it is always 1 pixel). This will avoid the pattern, but it will mean the tiles and the grid will be different scales and will probably look bad.
For a game, I would recommend getting rid of the grid and rethinking the design. If this is an app, such as a drawing program, then drawing the lines manually at 1 pixel is probably your best bet. You can see some of the functions here.
https://docs.godotengine.org/en/stable/tutorials/2d/custom_drawing_in_2d.html