You can't really say exactly which actions result in a suspension, let alone how long. There are a variety of behaviours that can ultimately result in a suspension and it's hard to list them all, especially since moderation is done by intelligent beings rather than robots checking activity statistics. The reasons are manifold, from simple rudeness, over voting fraud, to repeated spamming of low-quality content. Basically, behaviour that's generally destructive to the community, be that socially or technically. Suspensions are mostly a way to give you and the community a timeout to calm down and recover from whatever happened, but yes, they also can have a punitive aspect to them. A general overview can be gained from this blog post.
But they are also an extreme measure and pretty much the last line of defense. In the usual case, you will have been contacted, warned or otherwise tried to be reasoned with by the moderators before a suspension happens. It doesn't just plop out of nothing, unless it is rather urgent, like stopping you from vandalizing your posts right now. If you're asking this out of fear of getting suspended for stumbling over the wrong stone, chances are high you'd be much aware that a suspension is likely way before it happens.
As to the amount of time, it depends. There is a general guideline of a week for the first one, a month for the next one and a year after that. This is usually adhered to, but might be varied (in either direction) based on other factors, like general network history, relation between suspension reasons, or careful judgment by the moderators. However, when you see something like a 10 year suspension, this is something absolutely rare for either particularly egregious cases or weird special conditions. Those are done by the SE staff themselves (site moderators can only ever suspend for 1 year maximum) and happen maybe a couple of times ever on the whole network.