Trunk randomly unlocking/unlatching?

I have a 2013 Mazda3 Hatchback and recently I've been having a ton of issues with the hatch randomly unlocking itself all the time. It will unlatch itself occasionally while the car is on or driving but the issue seems to mostly be when the car is turned off. Without fail the second I turn the car off, the trunk unlatches and keeps unlatching itself constantly. It gets very annoying because I can't lock the car unless the hatch is completely shut so I have to shut the hatch and lock it quickly before it automatically unlatches itself again. The issue only seems to happen when I'm close to the car with the keys, but it doesn't seem to be a problem with the keys because even when I take the battery out of the keys, the trunk still relentlessly unlatches itself. Also the button on the hatch itself seems to no longer work and I'm forced to open my trunk with the keys which is mildly annoying. I have a feeling the two issues may be related in some way. Has anyone else experienced issues like this?