Formation of exotic atoms by direct capture and via transfer from hydrogen