Some questions about the Tilemap API

I’ve been struggling with tiles in unity 2D for some time and I can’t figure out how some basic things work…
Supposing I have a very simple Grid object containing a Tilemap, like in this picture:

  1. How exactly are the tiles stored inside this Tilemap object (they are stored in there, right?)? Are they stored as a 2D matrix? If yes, then where in the world is tile[0][0] placed? Also, how can I get the width/height of this matrix thing? I noticed I can get a tile by using a Vector3Int, but I could not figure out on my own how it all works.

  2. I would want to iterate through all the tiles, left to right, top to bottom. For each tile, I would want to swap it with another tile if the tile is of a certain type. I noticed these are by default BaseTiles. So how exactly can I check if a tile is a grass tile and swap it with a water tile?

Thanks for reading so far! Any help is welcome!

Hi, for 1) check unity - How to get all tiles from a Tilemap? - Game Development Stack Exchange

for 2) here are described different approaches to tiles and its sprites and the final one is to display a different sprite in the tile based on logic.

I hope it can be helpful, currently my tilemap’s knowledge is not wide enough to go deeper:)