Suppose that $Q$ has columns $q_1,\dots,q_n$. We can then write the matrix product as $$ Q^*AQ = \pmatrix{q_1^*\\\q_2^* \\\ \vdots \\\ q_n^*}\ A \ \pmatrix{q_1 & q_2 & \cdots & q_n} $$ With block-matrix multiplication, we can write this product as $$ Q^*AQ = \pmatrix{q_1^*Aq_1 & \cdots & q_1^*A q_n\\\ \vdots & \ddots & \vdots\\\ q_n^*Aq_1 & \cdots & q_n^*Aq_n} $$