I have experienced the same sound when my Mazda 3 is turned off. From what I have read in other forums, it may have something to do with Mazda 3s equipped with the Technology Package (cooling fan for the NAV or something to do with the push button start?). But whatever is causing the sound, with a little testing I think I figured it out how it operates.
It seems that the sounds starts as soon as you open the door, and it will continue indefinitely (not sure how long - I tested it for about 15-20 minutes) ONLY IF the advanced key is present in the vehicle. However, when I left the advanced key in the house, got in the car and closed the door, the noise stopped after just a few minutes. This was reassuring since my worries were that something was continuously running and would eventually drain the battery if the car was sitting and not started for several days.
Again I am not exactly sure what component is causing the sound, but it appears that it does shut off after you exit the car. Test this out yourself and see if you get the same results.