There is an electrical connector on the Compressor which is faulty.
I think that is the Problem. My old SV21 Camry used to do the same thing when it was only a few years old.
Trying reading the owners manual, if you have one. I t may give you a clue.