Formation of massive disc galaxies in the IllustrisTNG simulation