I’m curious, how is it more safer inside a building than being outside?
Buildings are built to resist earthquakes. Outside, anything (electric poles, roof tiles...) can fall on you.
Japan has had earthquakes forever. Their building regulations mandate things like isolation and dampers.
It all stems from an earthquake in 1923 in Yokohama which killed 140,000. Since then Japan's has over time developed some of the strictest seismic standards.
Modern buildings like hotels are built to withstand earthquakes of some magnitudes. Wouldn't count on that at a local construction site or a worn down house you might pass on the street.