Check all your connections to the battery, grounds, and starter solenoid. Sounds like you have a bad connection somewhere that sometimes makes connection and sometimes don't.