In this paper, we study algorithmic questions concerning products of matrices and their consequences for recognition algorithms for polyhedra. The 1-product of matrices $S_1$, $S_2$ is a matrix whose columns are the concatenation of each column of $S_1$ with each column of $S_2$. The $k$-product generalizes the $1$-product, by taking as input two matrices $S_1, S_2$ together with $k-1$ special rows of each of those matrices, and outputting a certain composition of $S_1,S_2$. Our study is motivated by a close link between the 1-product of matrices and the Cartesian product of polytopes, and more generally between the $k$-product of matrices and the glued product of polytopes. These connections rely on the concept of slack matrix, which gives an algebraic representation of classes of affinely equivalent polytopes. The slack matrix recognition problem is the problem of determining whether a given matrix is a slack matrix. This is an intriguing problem whose complexity is unknown. Our algorithm reduces the problem to instances which cannot be expressed as $k$-products of smaller matrices. In the second part of the paper, we give a combinatorial interpretation of $k$-products for two well-known classes of polytopes: 2-level matroid base polytopes and stable set polytopes of perfect graphs. We also show that the slack matrix recognition problem is polynomial-time solvable for such polytopes. Those two classes are special cases of $2$-level polytopes, for which we conjecture that the slack matrix recognition problem is polynomial-time solvable.