The axis are based on the cartesian coordinate system for 3 axis. Drafting systems from which parts are produced are also based on this system.

Basically, if you are looking at a drawing sheet, left to right is the X axis and belly button out to infinity and beyond is the Y axis. Anything standing vertically fromthe sheet is the Z axis.

This work well for Mills. For Lathes, programmers have adopted the powered axis as Z and the axis across as X. Think of a bench mill laying down.