It was and is a sign of good and proper etiquette to bow or doff your cap or hat when times call for it to be done. Usually it's a sign of respect for a person, or in tribute to the dead, or during tributes to a nation or a cause. It's generally a sign of respect and honor.