There are two types of bans: automatic timeouts and staff-reviewed bans.
Timeouts occur if you have been reported very frequently. You can tell that you have received a timeout because the top of your ban message will read "You have received an automatic timeout for:" and then give the report category of the last report you received. This may not always match up with your in-game behavior, as others may perceive you as underage, or using terms that they consider discriminatory.
Bans occur when staff review your moderation history and decide that you need to be removed from game for some period of time, or permanently. Another reason a ban can occur is if you have received an excessive amount of reports from both players and moderators. You can tell that you have received a ban because the top of your ban message will read "After a review of reports, you have received a ban for:" and then give a report category and often will include more details. For the most part, bans will be placed some time after the reports, as staff will need to review the reports.
For both bans and timeouts, there will be a countdown at the bottom of the ban message, unless the ban is permanent.
If you wish to appeal, please click here for more information about appeals.