In Narita airport (Japan), all passengers arrived by train are screened prior to entering the airport, and their baggage is subject to search there.
And that’s peaceful JAPAN. What if they were at war, and their biggest building had been taken down?
Oh —all resident foreigners must carry a foreigner ID card....
Which is hard to get, and if you don't have one, you can't function.