Create a X discount for every Nth product from the same category
Depending on how you've constructed your product data model, the Per-quantity category discount (% off) offer type supplied by the Commerce Discount Extra module should just work. It lets you specify how many products of which product category must be present on an order before the next one is discounted by any percentage (e.g. buy 2, get 1 free - 100% off). It's repeatable, meaning you can apply the discount any number of times on the same order so long as the right quantity is present, and you have some rudimentary sorting options - e.g. discount the cheapest or most expensive first.

If that solves it for ya, mark this answer as accepted. If you need a little more detail, feel free to add a comment and I'll help if I can. : )