They come from two different conventions for aligning the world axes. These conventions are known as Z-up and Y-up.
In mathematics, engineering and most every field but computer graphics, the convention is for the X axis and Y axis to represent the ground plane and the Z axis to point up.
When computer graphics was in its infancy, the X axis and Y axis were associated with the width and height of the screen. When the Z axis was added for 3D graphics, it was natural for graphics programmers to think of Z as being "in" and "out" of the screen.
This, in itself, is not incompatible with mathematics and engineering. It just means that the default direction that a camera looks is down towards the ground plane.
However, some of the early computer graphics programmers found it more intuitive to think of the default view of the camera to be parallel to the ground, similar to the way their monitor was arranged in their office. This led to them thinking of Z as being forward/back in the world and Y being up/down.
Modern games use both conventions and major content creation tools like Maya support both.