A 14-year-old boy was mistakenly arrested during an investigation into a suspected terrorist plot, police have said.