It just might be that the families wanted photos of the former President with them at the event.
They could have brought their own, or just had private photos of him with the family. That's not what we've gotten.
At least the argument can be made that Trump showed in remembrance of their fallen.
His campaign is openly using it for political advantage. That's just wrong. I'd contrast that with Bush, who met the family of every single service member who fell in Afghanistan/Iraq during his Presidency. Not only did he not bring a photographer or videographer into those meetings, but no press at all was allowed near and it didn't leak until much later.
This was clearly a political stunt.
How that is used by whomever is moot. Just being there would have been something that could be used against the Harris/Biden bunch, regardless of his personal motives, which some will attribute to politics, no matter what, even without pictures.
It isn't moot when it is his own campaign that is affirmatively using it as political fodder. We literally have the video now being shown how Trump supposedly was in step with a military guard as if that proves his greatness.