According to Thomas Kelly's "Moon Lander: How We Developed the Apollo Lunar Module", the primary driver for the positioning of the LM RCS quads was avoiding contamination of the windows with rocket exhaust:
We argued engineering logic and practical issues, such as jet contamination effects on adjacent areas of the ascent stage. This latter consideration convinced us to abandon the originally proposed RCS configuration, which had four jets close to the front windows, likely to obscure the windows with rocket-exhaust products. ...
Bob Grossman jumped up and took the chalk from me, his face glowing. He vigorously erased the blackboard and began to sketch. "Here, how about this?" we said as he continued to sketch. "We'll mount the thrusters at forty-five degrees, keeping them away from the windows. And we'll arrange them as an axial pair [X-axis aligned] and an orthogonal pair (Y/Z axis). ...
It looked better than any other the others, but we continued discussing its pros and cons for another hour before choosing it as the preferred design arrangement.
In vacuum, a rocket exhaust plume rapidly expands into a cloud, so each use of the thrusters would leave a thin deposit of material on the windows, clouding them slightly.
This leaves unclear why the CSM RCS layout remained with (nearly*) axial placement, particularly since it imposed a need for some thermal protection on the LM's legs due to exhaust impingement during docked flight.
The configurations are, essentially, functionally equivalent, and there's no obvious large advantage to that configuration. It may have been as simple as the CSM design having been more complete before the LM's RCS layout was decided.
* note that the service module RCS quads are mounted about 7º off the reference axes of the spacecraft.