A federal marshal knocks on your door. You panic: a marshal is a law officer. What do you do? You marshal your thoughts, that is, put them in order.
Marshal derives from the Old French mareschal, for stable officer. The stable officer had charge of the horses, tending to them, putting them in order, readying them for action. If you are a marshal, you're an officer. If you marshal yourself, you get yourself ready, preparing for action.