We consider optimization problems involving the multiplication of variable matrices to be selected from a given family, which might be a discrete set, a continuous set or a combination of both. Such nonlinear, and possibly discrete, optimization problems arise in applications from biology and material science among others, and are known to be NP-Hard for a special case of interest. We analyze the underlying structure of such optimization problems for two particular applications and, depending on the matrix family, obtain compact-size mixed-integer linear or quadratically constrained quadratic programming reformulations that can be solved via commercial solvers. Finally, we present the results of our computational experiments, which demonstrate the success of our approach compared to heuristic and enumeration methods predominant in the literature.