@Merry Andrew,
During the French and Indian War, an expedition lead by General Edward Braddock marched across western Maryland to attempt to take the French fort at what is now the site of Pittsburgh. Crossing Turtle Creek a few miles from the fort, the column of about 1,400 regulars--red coats--with a several dozen "rangers" and around 200 of the Virginia militia regiment was attacked by a force of about 90 Frenchmen, a hundred Canadian regulars (the colony of New France had its own regular forces) and couple of hundred Indians. The Canadians decamped almost immediately. They were happy to fight "Indian style," but were unwilling to face European troops in a stand-up fight. Having no choice, the French commander spread his handful of me out in the underbrush, instructing them to take their cue from the Indians.
The English column had to cross the Monongahela River twice, and having crossed it the second time, were just crossing Turtle Creek (now in the eastern end of Pittsburgh) when they encountered the French and Indians. The grenadiers in the lead fired effective volley fire, killing the French commander and convincing the Canadians they had better things to do, but the French second in command allowed the Indians to fall back into the underbrush, and spread his few French regulars out among them.
Thinking they had brushed aside an advance guard, the grenadiers fanned out on either side of the trail as it lead from the crossing of Turtle Creek, and the regiments following them passed through their position, looking for open ground on which to deploy. As the trail curved to their left and went up a gentle slope, they were fired on by the French and Indians, while the Indians began to whoop and holler. Unable to deploy into line, unable to see who was shooting at them, the red coat column began to dissolve into panicked clumps of men who ignored their officers and began firing wildly in virtually all directions. The regiment behind the van, taking fire from a force they could not see (it was actually their own men, but hidden by the forest and the curve of the trail), began to pour volley fire into the woods to their front, despite the attempts of their officers to get them to cease fire.
Washington, who had come on the expedition despite being very ill, was the senior officer of the Virginia militia present, and when their Captain asked to be allowed to deploy on the right flank to roll up the French and Indian line--they could see where the fire was coming from and what needed to be done because this was fighting of a style with which they were accustomed--Washington urged him on and told him to hurry.
Now the red coats had a target they could see, and they poured volleys of fire into the Virginians, despite the fact that they (the militia) were wearing blue coats, rather than the white coats the French wore. About 20 of the Virginians were killed outright, and their Captain quickly realized that it would be suicide to attempt to take his few hundred men further while being fired on by both the French and Indians and the redcoats, so he withdrew with his survivors, coming back later for his wounded. This the Virginians did while the English officers were attempting to put their men in some kind of order, and organize a retreat. The French, Indians and Canadians had already retreated by that point.
Braddock had ridden into the confusion soon after the firefight began. He was hit almost immediately (most of the English officers were killed or wounded, usually by their own men), and mortally wounded. Washington took charge of the retreat, because he was intimately familiar with the ground over which they were moving, and by that time the English officers were bickering with one another, and no longer trusted one another. Braddock died of his wounds three days later. Washington had him buried in the road to the east of their camp, so that as the demoralized little army marched away, they would obliterate the evidence of the grave, preventing the Indians from finding it and digging up Braddock's remains to be desecrated. Braddock's remains, or what were very likely his remains, were found in western Maryland in the late 1820s when the National Road linking Washington and St. Louis was being built.
General James Abercrombie lead a force representing the largest army of Europeans ever assembled in North America that went north on Lake George to take Fort Carillon from the French (this fort was later named Ticonderoga) three years later. The commander was not competent for the task, but his second in command, George Lord Howe was not only competent, but enjoyed the complete confidence of the officers and men, British and American, and was idolized by all the private soldiers.
Landing at the north end of Lake George in the first week of July, 1758, the Americans began marching north to clear an approach march for the main force of the Army. They were under the command of George Lord Howe, who was in the middle with a small force of rangers between the lead regiment of Connecticut men and a regiment of Massachusetts men following. A French force intended to delay them was cut off in their attempt to slip past the Americans, and a firefight broke out. When Howe's small body of troops came up, the Connecticut men panicked, thinking the French had got in their rear, and fired into his column. Lord Howe was killed instantly, and the entire expedition went to hell thereafter. Despite heroic efforts on the part of the Americans, the red coats and even the famed Black Watch, the Marquis de Montcalm held the fort in the teeth of repeated assaults by a superior force.
Two months after the Carillon debacle, and three years after the disaster of Braddock's attempt to take Fort Dusquense, General Forbes lead an expedition of red coats and the militia regiments of Virginia, Maryland and Pennsylvania to take the fort. While on the march, and in western Maryland not far from the place where Washington had had Braddock buried, the Pennsylvania troops had been halted at the side of the road as dusk fell. The Virginians were marching through the underbrush on the other side of the road, and when some of the Pennsylvanians called out to them, apparently in German, they fired on the unseen men. The Pennsylvanians returned the fire, and the firefight was only quelled when Washington road between the two forces, knocking muskets up with his sword and shouting orders to cease firing.
At Stony Point in New York, south of West Point, in July, 1779, the American forces launched a night attack against the heavily fortified peninsula in the Hudson River, which the English had recently taken from the Americans. It was a night attack, so the men had their cartridge boxes taken from them, and their officers circulated among them to make sure their muskets weren't loaded. This was done expressly to prevent "friendly fire" incidents when the enemy's works were stormed, and it had the added felicitous effect that most of the English didn't even know they were under attack until the Americans were among them with the bayonet.
When Alexander Hamilton lead the assault on Redoubt No. Ten during the siege of Yorktown in October, 1781, he took the same precautions, and the Americans assaulted with unloaded weapons, relying on the bayonet. They were completely successful in under 30 minutes, and had only nine men killed, and a couple of dozen wounded. Another night attack, the low casualties can only be attributed to the fact that they did not have their muskets loaded, and they overwhelmed the defenders before they were aware of the size of the force attacking. The French were assaulting Redoubt No. Nine at the same time, and their casualties were very heavy, in large part from firing into their own troops. They were repulsed, and only took the English outwork after the Americans had taken No. Ten and turned the guns there on the defenders of No. Nine.
I can multiply examples such as this for pages and pages. Thomas "Stonewall" Jackson was severely wounded by troops from his own corps during the battle of Chancellorsville in 1863, and died of his wounds three weeks later. His counterpart in Lee's army, James "Peter" Longstreet was also severely wounded by his own men a year later and four miles away. Intelligent officers from both sides believed that if Longstreet had not been wounded, by his own men, Lee's army would have driven Grant's army back across the river.
In all of these cases, bodies of trained men with experienced and competent officers fired on one another (except the two examples from the Revolution, in which their officers took steps to prevent this), each side believing they were defending themselves from a surprise attack. How much worse is this sort of thing likely to be when a bunch of yobs with handguns starting popping off rounds in a confused situation?