I guess it's not completely non-sensical, but it's not like there's any reason why the section over the bridge needs to be I-787. It's already NY 7.
I'm pretty sure the reason is to have an Interstate designation serving Troy. (And not just being fussy about city limits–you literally have to cross the river to get to Troy there, so that's why they would have sent the Interstate that way.) And also, NY 787 was not yet a thing when these designations were dreamed up, so there would have been no reason
not to end it in Troy.
If it happened today, it may well be different, but it was some years ago, and those decisions were never undone. So it remains to this day!
There's certainly plenty of examples where the through roadway makes a turn and another route continues straight, but this has to be one of the only examples where the route that makes the turn and the route that continues have the same number. This means that technically three of the four approaches to the NY 7/I-787/NY 787 interchange have the same number.
It's a quirk, to be sure. But you do also have a similar situation with I-890/NY 890. I'm not sure exactly where FHWA thinks I-890 ends, but I'd bet it's not a seamless thru transition onto NY 890.
And then there's I-790…
Technically it starts where the exit 23 toll booths were (the lanes to US 9W where the Southside Route was supposed to be are reference route 912S).
I know NYSDOT made that swap. FHWA's map suggests they eventually did too, but that seems to make their mileage figure just a bit high.