In this paper, the Hermitian reflexive (Anti-Hermitian reflexive) least-squares solutions of matrix equations $(AX=B, XC=D)$ are considered. With special properties of partitioned matrices and Hermitian reflexive (Anti-Hermitian reflexive) matrices, the general expression of the solution is obtained. Moreover, the related optimal approximation problem to a given matrix over the solution set is considered.