[deleted]
I suspect the question is based on a...let's just say incomplete understanding of Japanese society and history. :-)
Japanese culture -- high culture and pop culture -- certainly did often concern itself with questions of honor and loyalty. However, that's a bit like watching American 1980's action movies and assuming from them that every American owns and knows how to use a gun, or reading a Medieval romance and assuming that knights were gallant and chivalrous. ;-)
Actual Japanese history is littered with examples of betrayal and retreat. Actual samurai rarely committed seppuku and frequently retreated in battle, for example. Just like American Westerns romanticized the idea of the lone gunman who protected the weak, but there aren't a lot of historical examples to back it up, Japanese stories romanticized honor and faithful service even though reality wasn't that black-and-white.
Further, those ideals of honor and chivalry as a code of conduct were mostly codified after the unification of Japan, as samurai had very little fighting to do and spent their time developing bushido as a specific outlook on life. Popular writers then promulgated the samurai ethic as a way of life for all Japanese people, particularly during the Meiji era as Japan sought an identity different than that of the other cultures with which they were suddenly competing.
Sources: S.R. Turnbull's The Samurai: A Military History primarily. Sanson's A History of Japan to 1334 is a helpful look at the evolution of pre-Tokugawa culture. I know I've read about the use of bushido as "propaganda" among popular Meiji writers, but I can't think of/find it right now.
Note: I am very much an amateur historian on this matter; I welcome corrections.
See this thread on how the Edo Bakufu was able to keep peace and order.