Can you be more precise in your question? Is it that the router isn’t square to the cutting surface (and if so, in which axis), or is it that the Z axis is further away from the surface at XMax vs XMin, or is the XY not square when you measure from XMin YMin to XMax YMax?
The latter two can be corrected through M666 software commands (very small deviations) or adjusting the endstops (larger deviations). If it is the router that is not square (perpendicular) to the surface, you can adjust using masking tape behind the router to adjust (search this forum for “Tramming” and “Tape”)
Here is an example