Agree with doctor Victor " the shear stresses exist in any plane which is not orthogonal (or parallel) to the load direction ". The ability of a rock plane to withstand shear stress is much less than its ability to withstand normal stress, so shear failure tends to appear along a plane in a UCS test.
In addition to the above insights, during compression test where confinement pressure is applied such as triaxial or polyaxial condition, shear stresses are developed leading to shear failure of the specimen in the weakest plane. Shear failure and not splitting are predominant in compression test with confinement pressure. Since confinement doesn't allow the rock to dilate but undergo shear in the plane of weakness.
Weisheng Du and Sunny Murmu have mentioned that the main causes of rock failure in the compression testing are shear stresses. As you know, among all planes there are some ones in which shear stresses reach maximum value. For intact rock specimen each this plane is a weak plane, because that's where the failure will begin.