Can a moderator resign?
Yes, absolutely, if they feel that the relationship isn't tenable going forward for any reason. The most common reason for this is typically great news for the mod - something new in their lives needs a whole lot of attention, typically in the form of a new child or job.
Moderation is a volunteer effort, these are people that say my enthusiasm for what my community is doing is valuable to me, I want to do everything I can to help.
Resigning in no way means quitting, it just means that they simply don't have time to offer any longer. We will revoke access upon request, with heaps of thanks, and usually some swag to boot.
Is it also possible for a moderator to be dismissed if many violations/complaints are made?
Moderators often by definition have to make decisions that aren't going to be popular, to say the least. We would not remove someone from their post unless they were actively harmful to the growth of their site, despite efforts by us to explain why this was the case. And even then - being at odds with us (Stack Exchange) isn't a reason to remove someone, as long as the dissention is respectful and reasonably categorized as possibly constructive.
If they're clearly acting in the capacity of a champion of their community, with consensus, we'd never dream of removing them.
Violation of the moderator agreement is very likely to lead to dismissal.
Or if a moderator is inactive for a long time will that cause dismissal?
Yes, if every effort we make to reach out to them results in crickets chirping, we have a leadership vacuum that we need to fill. This usually takes months to come about, not weeks, not days.
The immediate needs of the site provides important context, however. If the site needs more moderator attention now, we'd clearly indicate that when contacting them, and act in the best interest of the site.
We're reluctant to remove a moderator without clear and compelling evidence that doing so would be more beneficial to their community than their presence as a moderator, and we understand and respect that people have lives.