Go to Illustrator or other vector drawing program. In Photoshop you can draw plain paths with no stroke and area fill as you like, but filled areas and stroked paths get rendered to plusminus one pixel accuracy:

The image is only 16 x 16 pixels zoomed in. It was divided to 2 equal triangles by drawing a path as you tried. The path looked perfect (from corner to corner) but the filled area became as shown above. There's no anti-aliasing.
Drawing to the corner is possible only if one has so high zoom in that pixels become well visible. There's no snaps nor smart guides like in Illustrator.
With Anti-alias ON you'll get a half transparent zone along the tilted edge:

The inaccuracy and anti-aliasing make well visible gaps if you have only 400 x 400 pixels. You'll meet the same also in vector programs, because perfect shapes are also there rendered to pixels. But there you can easily add a stroke or make the shapes otherwise to overlap.
In Photoshop you can as a workaround have 2 layers per a square: the top layer contains a triangle and the bottom layer contains the full square. But that's not at all handy, because you cannot easily draw perfectly without snaps.