My history is a little fuzzy, but if I remember correctly, we lost because we forgot the lessons of the revolution: guerrilla warfare against a superior (trained and equipped) force. Whenever we went head to head with the Brits in open field battle, we got whooped. When we hid behind trees and cottonbales, we kicked ass.
There was no reason, in 1812, the US had to fight a guerrilla war against the British. We weren’t a rebellion, we were a nation that had 40 years to build a military capable of going toe to toe with anybody.
In particular, a guerrilla force, by definition, was incapable of protecting the national capital.
After some initial and highly shameful reverses, the Army recovered and performed quite well under Scott, Brown and others in open field battle against British regulars. The US Navy showed throughout the war that they were perfectly capable of going toe to toe with the RN, given roughly equal forces.
And, of course, Jackson took an outnumbered incredibly motley force and nevertheless handed the Brits one of the worst defeats in their entire history.
IOW, there was no reason at all for the Brits to have been a “superior trained and equipped force” other than our own initial hubris.
We, BTW, learned that lesson, and have never since performed shamefully in combat in the same way.