map non unique attribute to a unique attribute
This will work with the sample data you have provided here. Your data could be entered into your tables in a way so that this will not work. If that is the case, please update your question with data that will show the issues you have.

;with TT as
(
  select table1_name,
         table2_name,
         row_number() over(partition by table2_name order by (select 1)) as rn
  from @TABLE1_TABLE2
),
T2 as
(
  select id,
         table2_name,
         row_number() over(partition by table2_name order by id) as rn
  from @TABLE2
)
select T1.id as T1ID,
       T2.id as T2ID
from TT
  inner join @TABLE1 as T1
    on TT.table1_name = T1.table1_name
  inner join T2
    on TT.table2_name = T2.table2_name and
       TT.rn = T2.rn