If you have a gate on the side of your house and the latch is secured through the stucco, you should probably prepare yourself for some maintenance. If you have to choose which side of the gate to hang on the stucco, I guess the latch would be preferred because it is not as heavy as the gate itself. However, as the gate will tend to slam into the latch and overtime will tend to loosen.
There are a couple of ways to deal with this problem. Some folks would consider moving the latch, which would mean you also have to move the gate by the same amount. You could also use longer screws and make sure they enter some framing lumber in the wall. Along with that you can repair the broken out stucco. They make a product which is basically mortar in a caulking tube. You can load this in a caulking gun, cut the top off, and squeeze some into the void under the latch. You will want to position the latch where you want it to stay while the mortar dries. I would leave it that way overnight. The next day it should be rock hard with no movement…until people start slamming the gate again.