Firstly, assassination attempt on political figure(s) != terrorist attack (at least not in the sense that the public were the target which is the only thing relevant to the claim we're discussing here (that we, the public, are safer due to our soldiers killing people in Afghanistan/Iraq).
Lockabie was an attack on American citizens which just so happened to affect people in Scotland because of the timing of the explosion and was a State sponsored attack which we did nothing about (in fact we got cosier with Gadaffi if anything).
None of the events you mention are Al-Qaeda linked, so sorry, the fact remains that until we invaded Afghanistan we were free from Al-Qaeda 'martyrs' willing to blow themselves up in an effort to take out British citizens.