it happens because both tables will return the same column name tableA_id, since you're fetching as assoc, it will create an array in which the first index will be rewritten by the second column value. You see how it works by playing this:

Note that if you were going to define a different WHERE condition (IS NOT NULL instead of IS NULL), you would not notice this error, as also the other columns would return populated. Check the examples here: