The War of 1812 was in part an outgrowth of the Napoleonic Wars in Europe. The U.S. decided to declare war on Britain in part because the British Navy was impressing Americans into serving on their ships; impressment of about 10,000 American merchant sailors was one of the major irritants that led the U.S. to declare war. In addition, the Chesapeake-Leopard incident, in which the British ship the HMS Leopard pursued the American frigate the USS Chesapeake off the coast of Virginia in 1807, was another cause of the war. The crew of the Leopard was apparently looking for deserters from the British Navy, and the ships were involved in a short battle. Afterward, the British government refused to back away from impressment, which was a vital issue at the time because the Royal Navy was such a brutal institution that many sailors tried to escape to other nations' boats, and Britain was involved in a war with France.
After the Chesapeake-Leopard incident, the public response was a cry for war, but Jefferson, who was President at the time, tried to use diplomatic solutions, to no avail. He passed the Embargo Act of 1807, which was intended to end all American imports to Britain and France. The U.S. wanted to trade with both countries and remain neutral. However, the Embargo Act largely only hurt American shipping. The other causes of the war were the desire for America to expand west, while the British gave support to Native Americans along the western frontier to prevent American expansion.
The war included attacks by the Royal Navy along the coast, including along the Chesapeake, leading to an attack on Washington, D.C. and the burning of the White House, U.S. Capitol, and Navy Yard. Once Napoleon left power in 1814, Britain and France became allies, and one of the causes of the war had ended.
Today, wars abroad also involve the U.S. For example, the devastating civil war in Syria, which has been going on since 2011, has resulted the migration of millions of immigrants to Europe and some to the U.S. Ongoing unrest in the Middle East has resulted in violence in the U.S. For example, al-Queda claimed that American support of Israel was in part the reason behind the 9/11 attacks, in addition to the American involvement in the Persian Gulf War. As the War of 1812 involved attacks on American soil, such as the burning of the White House and U.S. Capitol, the events of 9/11 also included attacks on domestic targets such as the Pentagon, in addition to hijacking planes.