Tokyo is really a place of many encounters. This encounter was already planned as all the normal Oni will die very quickly, we need to get to the next phase quick.
@DoubleLu2You The beginning of chapter 7 shows that this story takes place during the Taisho era, between July 30, 1912 and December 25, 1926. Western influence on culture had been growing since the Meiji era prior, so the fedoras shown here would not have been an uncommon appearance. There may have been electricity available too, but it wouldn't have been common outside of larger metropolitan areas like Tokyo. You can see how Tanjiro is suprised that the city being very bright even at night, probably because of the availability of electricity.