We're all at a loss, aren't we? Norway has just about the highest living standard in the world, extensive social security networks, etc, yet it produced Anders Breivik. I don't think there are clear answers to any of this stuff. Even in a virtually ideal society, people would come along who would do terrible shit.
Aside from the obvious - stop starting wars and get out of the ones you've already started - I don't have any particular ideas wrt Britain, although 'don't start wars' is a very good place to start, I think, if you're serious about not producing violent extremists.