You can do this for a single product through tiered pricing: https://docs.magento.com/m2/ce/user_guide/catalog/product-price-tier.html
To apply the discount to multiple products, you can set a shopping cart price rule that will apply to multiple products: https://docs.magento.com/m2/ce/user_guide/marketing/price-rules-cart.html
https://docs.magento.com/m2/ce/user_guide/marketing/price-rules-cart-create.html
A cart rule does not require a coupon code, and can, therefore, be automatically applied to items in the cart. In terms of conditions that apply a discount, you can use logic statements to determine that if there are Greater than "x" items in the cart but fewer than "y" items that match a particular category or attribute, the promo should apply.
You can then specify the discount % as an Action. In the Actions tab, be sure to specify which products the discount should apply to (ie. only products in the cart that match an attribute or other criteria), or the discount will apply to everything in the cart.
Be sure to test your rule. In the example you shared, you'd definitely need to create multiple rules (one for 6 or more pieces, another for 12 or more pieces, etc.).
If you'd like to offer more complex cross-catalog promotions, you might consider an extension that will allow for that logic to be used in the Magento admin, such as: https://marketplace.magento.com/amasty-module-special-promotions-pro.html
Best of luck!