6.0 randomly starting on its own
So I've had this 2004 f350 for about 6 months now and I've encountered a very strange issue. To preface, I bought it from a friend who had it for a few years and while I was taking it for a test drive, I asked if there were any issues that he was aware of. He mentioned a few things and then told me a story about one time he had been driving it home, turned truck off and took the key out of the ignition and the truck wouldn't turn off. I believe he said he ended up disconnecting and reconnecting the batteries and turning the ignition on and off and he got it to turn off. He said that was the one and only time it happened to him.
Well, fast forward to 3 months after I had it and my wife called me and told me she took the truck out to the store, brought it home, turned the truck off, and locked the door with the fob, and suddenly, the truck just turned back on... with no key in the ignition. She got in the truck turned the key to on, and tried turning it off. The electronics inside would turn off, but the engine kept running. She turned it back on, put the truck in reverse, put it in drive, then back in park, and she was able to turn it off.
The other day I went outside to grab something out of the truck after it had been off since the previous day, locked the door with the fob, and a few seconds later, once again the truck turned on. I repeated what my wife did to turn it off and it didn't work. I drove it around the block and came back and was able to turn it off.
These are the only 2 times in 6 months of driving that it's happened
TL;DR The engine seems to be turning on infrequently when locking the door with the fob and won't turn off with the key.
Any idea what could be causing this? My mind jumps to something in the circuit that controls the locks shorting onto the starter circuit or something like that, but why am I not able to just turn the truck off with the key if that's the case? I also thought maybe there was some sort of aftermarket fob mod that could start the truck by entering some sort of combination but I can't seem to recreate this phenomenon at all.