The consistency of the design is not done by the choice of colors or its quantity, but by the design itself. The color is just one more component within the design guidelines.
If you define color variability in the design guidelines as a design component, the color change in the buttons can be an element of manifestation of this variable, provided that the shape of the buttons is sufficiently personal and recognizable.
A clear and extreme example of the use of different colors in design is the Carrefour supermarket logo. Although one of the basic canons in corporate image is the consistency of unique and representative colors, when Carrefour presented its new design in 2009, it did so with a considerable number of gradients to be used in its different communication needs.

Page from the Carrefour Brand Book
I think the problem is not the color of the buttons in relation to the theme of each product but the color of the buttons in relation to the design guidelines of your website.
This design guidelines can define that all the buttons must keep the same color or vary according to the theme, both options are valid.