I'm not an expert on this, just have worked through my share of problems with HVAC.
I've had something similar happen when a relay was bad and needed replacement in at least two homes. Also had some issues with wasps getting into a box in another home...beat on it a bit and it started working again.
I've also had some similar trouble when the compressor was nearing the end of its life. It already had the largest capacitor for start up, and then it burned off a terminal block which had to be replaced. It would try to engage the compressor, fail, then try again a short while later.
Probably best to call someone out and do some quick maintenence, check the charge, etc.