This is an interesting case! I originally thought it was due to the fact that, as @Andrew says in a comment,
\node has a border. However, that border can be removed by setting
inner sep and
outer sep to
0 and this is exactly what you do. So the node does not have a border.
What is going on is that the inner
\tikz picture has a border. Exactly why this is so is quite subtle. When TikZ builds a picture then internally it keeps track of the size of that picture. The main way of doing so is to keep track of a rectangle that is big enough to contain every coordinate that has been used, this is enough to ensure that every path is inside the picture (there are some questions about this with relation to Bezier curves which are an interesting read). However, when a line is drawn then it is drawn with a thickness and so if a path goes between, say,
(1,0) then its maximum height will actually be a half linewidth above
0. So when TikZ adds a point to the bounding box, it actually adds a half linewidth beyond it. So when you create a picture with coordinates
(1,0) and (for ease of explanation) line width 2mm, the bounding box will have corners
(1.1,.1). And this extends a bit beyond the line.
When this is embedded in another node (I would go one stronger than @Andrew and say that nesting TikZ pictures should be avoided), the outer TikZ doesn't know anything about what the inner TikZ drew and just knows about the box size. So it creates a node big enough to contain that box. Even though you make that node as tightly fitting as possible (via
inner sep=0, outer sep=0) you don't make it touch the inner line.
The solution proposed by @AboAmmar gets round this by making the line in the inner TikZ picture extend to the boundary of the inner picture since
line cap=rect ensures that the line extends by half a line width beyond the coordinate. This works in the case of horizontal/vertical lines as then the overreach of the line exactly matches the excess added to the box, but the situation with a diagonal line might need more adjustment.
(I'm actually going to remember this one as another example of why nesting tikz pictures can cause strange effects and therefore is Not A Good Idea. If you have a situation where you think you need to nest tikz pictures, please ask here first and someone will come up with an alternative solution!)