I don't have an exact answer for how they decided exactly what to attack, but:
The base on the left is within your pollution cloud. Spawners absorb pollution and use it as a resource to generate attack waves. You should plan to destroy every base that is exposed to pollution — this will greatly reduce the frequency of attacks. (You can also use efficiency modules to decrease the pollution output of buildings, but I imagine you're not to that tier of items yet.)
Regardless of pollution (I think), they will also send out groups seeking to build new bases in empty land, but if those exploration parties meet your buildings, they will attack instead.
You are very close to both of the bases on the left. You should remove them or expect to need to defend against them constantly.
Myself, I prefer keeping a wall and turrets completely encircling my base, rather than leaving any gaps at all, but some players build 'pillboxes' instead (groups of turrets). But in general, you should have some automated defense for all sides of your base — any open land, even without nearby bases, will sometimes get biters wandering across it, and even building new bases in it.