A trade deficit occurs when a country imports more goods and services than it exports, resulting in a negative balance of trade. This imbalance can lead to various advantages, such as a wider variety of products and improved living standards, but also presents disadvantages like unemployment and inflation. The formula for calculating trade deficit is total value of exports minus total value of imports.