when you push in the button, it:
a.) pops back out again without sticking
b.) pushes in and out like you'd expect
if (a),
when you hold the button in, it:
c.) turns hazards off
d.) nothing, hazards stay on
if (c),
replace your hazard light switch, they cost $30ish at the dealership and take a flathead screwdriver and 2 iotas of common sense to replace
if (b and d),
when you lock your doors, it:
e.) acts normally, what a dumb question
f.) well gee, they just unlock again, how odd
if (e),
you likely have a short circuit somewhere along the line. The first place that I'd look is at the wiring harness that rubs when you close the trunk. You can find it.
if (f),
it's your BMW crash sensor gone wacky. Replace.
That gives you a place to start, at least. Hope it's helpful!