You leave the borders open. If a terrorist comes across the border, you send the police to arrest them. You arrest criminals and prosecute them. Why is this so hard? You only need a completely separate organization if you want to control the numbers of people coming into the country. If you don’t care who comes, and just want to make sure there aren’t violent criminals coming in, the police are more than capable of handling that.
You leave the borders open. If a terrorist comes across the border, you send the police to arrest them. You arrest criminals and prosecute them. Why is this so hard? You only need a completely separate organization if you want to control the numbers of people coming into the country. If you don’t care who comes, and just want to make sure there aren’t violent criminals coming in, the police are more than capable of handling that.