“Obey the law” does not mean submit to authority. Martin Luther King believed in nonviolence and Malcolm believed in self-defense, but they had more in common than not, including a preference for legal protest. It's tactically wise. A speaker is more effective in public than in prison.
Because Malcolm believed in self-defense, his “if” is essential: Has no one laid hands on you? Stay peaceful, courteous, and respectful.
Nothing in his code kept him from demanding justice, as you may see by watching any of his speeches or interviews.
Possibly relevant: I discuss cowboy codes of the early 20th century in A little about America's idea of cowboys and traditional male values. They have a lot in common with Malcolm's code.