Custer's enemy was equally armed, but greatly outnumbered Custer. It was the classic military debate of quality versus quantity. Motivation and morale was also on the Indian/Native American's side.
Mogadishu was mostly an Army battle, few Marines. Some SEALS and Air Force as well. Again, it boils down to numbers mostly. Essentially "human wave" tactics by the Somalis, willing to take huge number of casualties to embarrass the USA into leaving combined with USA political constraints on how much firepower to use since there were thousands of civilians being used as shields.
...
The SNA leadership had the express goal of expelling U.S. forces from Somalia following the
Abdi House Raid, and knew that the Americans would not be able to tolerate casualties, especially in a conflict they had no real stake. They believed that inflicting any notable casualties on the Americans would cause Congress and the public to turn against participation in
UNOSOM II and withdraw from Somalia.The SNA's objective was not to achieve a tactical military victory against the Americans and UNOSOM, but to sap their will to continue fighting and force a complete disengagement from Somalia. In
Losing Mogadishu: Testing US Policy in Somalia, Johnathan Stevenson argued that the Americans had not recognized that, much like the North Vietnamese guerrillas, the Somali National Alliance was deliberately executing a military philosophy of attrition in order to achieve victory in spite of a high kill ratio, knowing they could absorb far more losses than the Americans would be able to tolerate.
...
en.wikipedia.org
What it really seems is that Left leaning politicians and strategists often fail to learn the lessons from history (Clinton POTUS during Mogadishu) which is why when Democrats are running the show, they usually botch it, cost more American lives and treasure than should, and fail to achieve their feeble goals.
Those on the Right; Conservatives/Republicans have learned the lessons better, and if not hindered and constrained by the Left will get better results. One key less is if you are going to do something military, don't do half-measures. Use your full load, don't hold back until the objective/goal is attained. This is what we are seeing as the USA and Israel deal with Iran.
There are a few other observations and lessons to be learned from the examples you present, but for another time and place.