The contragredient transformation A bar right arrow P-1 AP-(inverted perpendicular) , B bar right arrow P-inverted perpendicular BP of two matrices A, B effects simultaneous similarity transformations of the products AB and BA. This work provides structured canonical forms under this transformation for symmetric or skew-symmetric A, B. As an application, these forms are used to study the quadratic matrix equation XAX = B, where both A, B are skew-symmetric or symmetric matrices. Necessary and sufficient conditions for the existence of a (nonsingular) symmetric solution X are formulated in terms of the structured canonical form.