Security services have foiled 13 potential terror attacks in Britain since 2013, with more than 500 active investigations at any one time.