Switzerland and Spain are both part of the Schengen area so no passport control. In theory your bags should be subject to customs checks on arrival in Spain, but very often they aren't or there's no-one there.
Madrid to Germany is also intra-Schengen so no passport control and no customs either, as both are in the European customs union.