If it's ok to have Ids from same group as comma separated column then you can use below query (It will ensure that both table has same number of duplicate ids for a given columnA or columnB value):
Schema (MySQL v5.7)
create table table1 (id int, columnA varchar(20));
insert into table1 values(1,'one');
insert into table1 values(2,'two');
insert into table1 values(3,'one');
create table table2 (table1_id int, columnB varchar(20));
insert into table2 values(1,'one');
insert into table2 values(2,'two');
insert into table2 values(3,'one');
Query #1
select a.ids from
(SELECT GROUP_CONCAT(id) ids
FROM table1
GROUP BY columnA
HAVING COUNT(*) > 1) a
inner join
(SELECT GROUP_CONCAT(table1_id) table1_ids
FROM table2
GROUP BY columnB
HAVING COUNT(*) > 1) b
on a.ids=b.table1_ids;
View on DB Fiddle