Even though the are both colonels, Montgomery was the brigade commander and therefore Shaw's superior in the chain of command.
Think of it like this, lets say Montgomery, Shaw and another officer all have regiments that they are commanders of. The three regiments are grouped together as a brigade. All three men are colonels but someone has to be held accountable for the actions of the brigade, in this case it's Montgomery.
Ah, ok. I see now. Thank you for the information.
"Vi Veri Veniversum Vivus Vici"
Yeah you don't typically have two officers of the same rank within a relatively small command structure like that. Typically a brigade commander would be a brigadier general (one star) but with the loss of so many officers during the war officers would get promoted or given commands that they really weren't qualified for.
It's like two captains, on two different ships. Once one captain boards the other captain's ship, the host captain is the commanding officer.
In this case, the "ship" is Montgomery's operation, and Shaw and his outfit were guests on the "ship". So Shaw followed him....