What is the difference between "连忙" and "马上" in Chinese?
连忙 = in a hurry; hurriedly (when you are in the hurry, you act immediately)
马上 = immediately (when you act immediately, it seems that you are in the hurry)
连忙道歉 = hurriedly (immediately) apologize
马上道歉 = immediately apologize (as if you are in a hurry)
You could translate 连忙 (hurriedly) as "immediately; at once" if you want to emphasize the 'swiftness' aspect in 'in a hurry' , but "连忙" (in a hurry) mostly emphasize the manner of how the action is being carried out
When you say 他连忙道歉 (he apologizes in a hurry) it strongly implies the action is immediate; When you say 他马上道歉 (he apologizes immediately) there is no need to add "in a hurry" because that would be redundant
马上 could be used in 祈使句, “马上起来！”, but 连忙 doesn't work since it's only descriptive.
连忙 as the characters suggests, sometimes it shows somebody is busy but got an unexpected incident, assumes he's being careful, humble, prioritizes the following action over what he's previously doing.
马上 simply means immediately, not necessarily in a hurry. it could be very confident action/reaction (while 连忙 doesn't sound like).
btw in the typical scene that 连忙 should be used descriptively, the corresponding word for 祈使句 is 赶紧. “赶紧道歉”, like a leader instructing some guy who made mistakes in interaction with other leaders.