Yes, this law is stupid. But it has been on the books (and is being enforced) since the country was founded in 1949. It was, in the past, even famously used to prosecute leftist insignia of a broken swastika being tossed into a rubbish bin.
This law is, in fact, on the books because of staunch American influence in the nascent Grundgesetz (the constitution of federal Germany). So this prosecution can’t surprise anybody who did their homework. The mitigating legal factors like educational material, history books or parody obviously do not apply here.