Make a 2d plane grid in 3d world

I’m trying to make an rts-game. To implement pathfinding I need to create a grid. I want the grid to fill the whole terrain, which is flat. So how do I create all these squares? I know the logic behind making a grid with a loop inside a loop etc.
But do I need to instantiate a lot of small planes, or is there some smart way to do this that I am unaware of? Like just drawing rectangles for each cell?

And yes I would like the grid to be shown visually if possible.

So where do I start from here?

EDIT:

I’d like something like this alt text