You might have to go through customs during a layover, especially if your layover is in the Schengen Area (which consists of most countries in the EU). For example, if your final destination is Paris, France, but you have a layover in Madrid, Spain, you will actually go through customs in Spain, not France.