The building up of observed stellar scaling relations of massive galaxies and the connection to black hole growth in the TNG50 simulation