Arduino UNO running sketch on its own when powering up.

This is NOT a problem with a sketch. The sketch has been working fine. But I need to explain the sketch so someone can tell me if my problem is hardware.

I have a password/keypad setup that activates one relay when the correct password is entered. When the # key is pressed, the 2nd relay is activated. The 1st relay triggers the unlock button on a key fob, which unlocks my Jeep doors. The other relay triggers the lock button on the fob locking the Jeep doors.

As I said, this sketch works PERFECTLY. However, I was about to update the sketch so I unplugged the UNO from the 5v power in the Jeep and brought it to my computer. When I plugged it in, I could not upload anything. I noticed, for some reason that in TOOLS, the Port had to be reset. For my UNO it is now set to: /dev/cu.usbmodem111 (Arduino/Genuino Uno). The Board is set properly to Arduino/Genuino Uno.

But here's the big problem where I need to know if there is a hardware or some other problem. When the Arduino UNO is plugged into my computer or back on the Jeep, one of the relays is automatically triggered continuously and is repeatedly locking the Jeep doors (which also honks the horn - a Jeep feature).

Here's some additional information and a test that may help. To stop the action of the relay, I simply uploaded a blank sketch.

I then decided to test a different sketch. This is a simple, stand-alone program that utilizes a keypad and piezo speaker/buzzer. The sketch will activate the piezo one time on each key press. However, with the piezo and keypad plugged into the UNO and when powered up, the piezo is automatically activated continuously - like that relay did.

And to clarify one last thing, both the relay or piezo activating on there own, happens even if the keypad is not connected to the UNO. The power to the Arduino only comes on when the Jeep is turned off. I have a special circuit that only works when the key is out of the ignition.

And as a reminder, the keypad, relays and key fob have been working for months - flawlessly. It's only when I disconnected the power from the Jeep to move the Arduino UNO to my computer that this problem started.

The settings in Tools:
Board:Arduino/Genuino Uno
Port:/dev/cu.usbmodem111 (Arduino/Genuino Uno)
Board Info
BN: Arduino/Genuino Uno
VID: 2341
PID: 0043
Programmer: AVRISP mkll

Which pins are you using?

Problem has been solved. After working with Arduino service directly to double check stuff, they send me a list of things they wanted to know or try. One of those happened to be trying the UNO on another computer. Since this project resides in my Jeep, I do from time to time update the sketch via a laptop. When I reuploaded the sketch using the laptop everything worked fine.

Long story short, the sketch on my desktop was not exactly the same as the one on the laptop. The bad sketch had an erroneous/misplaced

if (key){

for the Serial.begin(9600); function.

Once I fix that everything was fine. I caught this after I sent my additional info to Arduino but before they got back to me. I must have been playing around with the Serial Monitor and forgot to either delete the code or fix it before saving. Luckily the laptop had the working version, which alerted me to the problem.