Knowing the format you're building a team for is very important, like what Pokemon and strategies you need to have answers to. If you have some Pokemon you know you want to start with, whether it's a mega, a favorite Pokemon, or just something you really want to try out, you have to identify what it'll have trouble with. Choose a Pokemon or two that can deal with those threats next, and then continue to build out from there. For singles, building out may include things like a hazards' user, hazards' removal/prevention, physical/special walls, etc., and doubles may include speed control, counters to Trick Room, counters to weather, etc.
Finally the most important part of team-building is practicing with it honestly. Wins are great, but losses will tell you the most about your team. Did you lose on a misplay or can your team just not handle something? If it's a misplay, you just learn and make a better play next time. If not, your team may need to change a Pokemon, spread, or moveset. Getting comfortable with using the team and knowing how to use it to counter other teams is what can even make teams that look mediocre "on paper" really good.