Unexpected results with soundex() function when combined st_distance()
The condition:

AND    A.name = B.name 


only allows identical names, while you obviously want to match names with the same soundex value. So make that:

AND    soundex(A.name) = soundex(B.name)


If gid is the primary key, you can also simplify to:

GROUP BY a.gid, b.gid


However, since there obviously is no aggregation at all, you can simply remove the GROUP BY clause.

As suggested by PostGis, consider ST_DWithin() instead of ST_Distance() in the JOIN clause. The latter cannot utilize a spatial index.