Really, all the cops need to do is say they smelled marijuana and they can go in. Most of them probably wouldn't, unless you were rude about it. But you never know, cops are people too, and you can't trust people.
What might have happened is that apartment complex owners sometimes request police dogs to run through door to door. It stops at your door. etc. You might want to get one of those little scent sticks. Looks like chap-stick, and mark everywhere. Along walls toward the bottom, neighbor's doors, the dog alerts everywhere that way, not just your front door. I imagine it wouldn't hurt to mark all over the inside too. If your stash is in a cupboard but the dog is alerting all over the place everywhere else too... Couldn't hurt.