I don’t know about Schengen but that’s not correct for Japan. You can get a visa to visit Japan from an embassy in a country you’re not a resident or national of, there’s no requirement for the visa to be issued in your country of nationality (although some embassies may choose not to accept applications from non-residents or non-nationals).