Its a known fault in Corolla 1.8 compressors (2014 and up).
The compressor is sensor-based, compared to its predecessors which were clutch-based.
Over time, the sensor malfunctions, causing the compressor to trip and ultimately fail.
Best solution is to replace the compressor with clutch-based ones, either from previous gen Corolla or any other Toyota models which fit bolt to bolt without any alteration.