The same orientation can be encoded using many different combinations of rotations, even Euler angles have many variants. The code snippet above uses ZXY rotation order - see complete conversion between matrix and Euler angles representation in this post: