First results from the TNG50 simulation: the evolution of stellar and gaseous discs across cosmic time