That sounds like either the door latch switches are not operating correctly (the car does not think the door is closed and latched) or the wiring between the A pillar and the door has a broken wire(s) that go to the door latch/lock system. Either one could cause the alarm to go off because the car is not reading the key as a known valid piece.
If you have access to a dealer level scan tool you can watch the switches and the alarm as the key is used and see if it is/is not reading the key or if it is because the door latch switch is not operating as it would show open/closed. However, you could scan it and show it is working and it could fail like it does now as it sounds like it can be intermittent. Sort of a catch 22.
I would start with the wiring myself as it is a common issue on many vehicles because of the way the wires flex as the door moves. You basically remove the rubber boot at both ends between the door and body and look for damaged/broken wires. A common issue is that the wire will break inside the insulation and look fine. Those can be hard to spot.
Images (Click to make bigger)
Tuesday, May 8th, 2018 AT 9:39 AM