Let $\mathbb{R}$ be given the standard topology. Then the closure of $(1,7]$ in $\mathbb{R}$ is $[1,7]$.
Let $(1,7]$ be given the subspace topology. Then the closure of $(1,7]$ in $(1,7]$ is $$[1,7]\cap (1,7]=(1,7]$$ but I'm confused as to why this can include 7?
We're considering $(1,7]$ as the full space and looking for the points in $(1,7]$ for which any open ball around it contains some point in $(1,7]$, but how can we even define an open ball around $7$ as it will have points outside the space (which seems similar to centering a ball around $\infty$)? And if we can do that (maybe via some empty set logic) then why can't we do that at $1$ and say $1$ is in the closure too?
You just ignore the part of the ball that sticks out. By definition of the subspace metric we just use $B_{(1,y]}(7,r) = \{x \in (1,7] : |x - 7| < r\} = (7-r, 7]$ for $r<6$. So instead of all points closer then $r$ to $7$ in all of the reals we just take those inside the subspace in question.
This corresponds to open sets in the subspace $Y$ of $X$ as sets of the form $O \cap Y$ for open $O$ (open in $X$). Outside the subspace the subspace "sees" no points, essentially.