Before you start a tabletop campaign, it can be helpful to talk with the players to establish a social contract - you should do this if you're playing with a new group. It's good to establish a number of things before you start playing - making sure everyone is on the same page, and has the same understanding of what game they're playing is vital for ensuring everyone has a good time - and most acrimony at a tabletop game comes from a clash in those expectations.
Let's say for example, one player thinks they're playing an adventure that's very PvE focused, all the characters will work together, and the players will take effort to make sure their characters get along. Another player thinks that each person is making their own characters with secret goals and motivations, and, during a critical encounter, backstabs the first player's character, killing them off. - Instant fallout.
The DM should arrange and talk with players, to make sure everyone understands what style of game is to be played, which things are acceptable at the table, and which things are red lines. This goes for game mechanics, party dynamic, the type of story being told, and roleplay content. Here are some good things to establish.
- Is this a "play the game strictly to the rules" type of game, or is this a loosey-goosey "rule of cool" style of game? How much freeform is there going to be, and how much "make it up as you go along" is there going to be?
- Is this campaign going to be mostly a game-mechanics focused fighting monsters and dungeon crawling game, or is it going to be a roleplay bonanza?
- Is PvP allowed? How much are players expected to work out their differences peacefully, and how much are they expected to get along?
- How much table talk and rules discussion do you want? is this a "DM's way or the highway" situation, or is it okay for players to argue rules and mechanics?
- What is the expectation of risk and losing characters in the campaign? Is it going to be a "lose a character every couple sessions" type of thing or a "death is rare but possible" kind of thing?
For roleplay content:
- ALWAYS establish if any players have any phobias or red lines. If a player is uncomfortable with graphic violence descriptions, gore, scenes of a sexual nature, descriptions of sexual abuse, torture, or other seriously distressing content, make sure all players know this is a hard "no"
- What level of flirting/romance is each player comfortable with. both between another player and themselves, and between two players not including them? Find the first threshold that someone would be uncomforable and "fade to black" before crossing that line. Different people may be fine with others roleplaying some things, but not want to engage in them themselves. Make sure all players are aware of this.
- Make sure all players know to speak up immediately if any roleplay or any scene is making them uncomfortable, and if it is, all players know to move the scene to something else rather than arguing that they get to continue.
For expectations for the campaign.
- Ask your players what they want to get out of the game, on an out-of-character level. Are they looking to practice improvisaion and roleplay? do they want to play the mechanical combat game? Do they want to be a big damn hero and win through encounters all the time, or do they want to experience failure and setbacks. Where do they want to be challenged etc.
- What kind of story do they want to tell with their character? is it a journey of discovery, to uncover some secret about the world? are they just looking to fit in? do they not care and just want to kill goblins with a big hammer. Do they enjoy being a murderhobo, or do they want to have challenging serious roleplay etc.
Sit down and discuss these things with each player, and also with the group as a whole - make sure everyone understands that they are playing the same game, and in general your chances of having a blowout are much reduced.
Wizards of the Coast have done a phenomenally bad job at communicating this stuff - this is the "session zero prep" that you do before you make characters. A player needs to know the expected tone of the table and campaign before making decisions on what character to build. You don't want to spend a few weeks building a detailed nuanced character with a lot of backstory and hooks for a "dungeon crawl monster slaughter fest where characters die if they step on a trap" style of game. A few more recent modules have approached some parts of this (RotFM makes a point of instructing the DM to talk to the players about phobias, for example.) - but... in general the hobby is bad at providing new players and groups with these guidelines, and they're fundamental to having a good time at your tables.
If you don't establish these guidelines, then it's just luck if you find a group that you mesh with.