World War II Japan is framed through recent, documented war crimes and racialized Allied propaganda, while samurai are framed through a much older, romanticized warrior ethic that was "cleaned up" and exported as an honorable, almost chivalric ideal. So you end up with Japanese soldiers in the 1940s as villains and premodern samurai as almost mythic heroes, even though both are part of the same national history.