Technically BA didn't buy IB, it was a merger and both carriers are a part of IAG.
IIRC, the original plan was for BA and KL to merge. KL was not in alliance at the time, and had the merger gone ahead, KL would have almost certainly joined Oneworld. This didn't work out and AF merged with KL and the latter joined Skyteam.
That only left one large European carrier, IB. LH obviously wasn't up for merging with anyone, having already taken over several smaller European carriers: SN, OS, LX and BD.
I agree that BA not merging with KLM was a big mistake, since it would have been a great partnership
At the time of the BA/IB merger, Iberia was doing well (better than BA for sure at the time) and was in OW, so at first it was a good idea, now I would disagree with the problems IB and Spain in general are facing
As for LH, it would be great for them to merge with BA, since a LH Northern European hub at LHR would be better than one at Brussels
Also they only own 45% of SN and they still have not bought the airline after all that time