Keeping the same fish or type together vary between the type of fish and ultimately your setup. The smaller the setup the hardier it is to keep certain fish together, even peaceful fish in small tanks can become very territorial making it harder to add other fish, not to mention some fish do need a good amount of space to survive. Larger tanks do elevate some of those problems but even then problems can still happen. In large setup some fish start to behave like they're in the wild and start to stake out areas of the tank, attacking any fish that swims by, even if it doesn't pose any threat to it. Some times you can remove the fish, add the new one, and then latter on reintroduce the old one and the problem may go away, though with some fish it just doesn't work, as they can become too aggressive, especially as they get larger. Wanting to keep different types of Tangs, Triggers, Angel, and Wrasses is usually why people have more than one tank, as it lets you keep more fish than if they had just one large tank.
A lot of times mixing fish together, the same fish or in the same group, can be accomplished by mixing different sizes, though in time fish do grow and what may work now can easily turn into a problem down the line. The smaller fish, which didn't have a problem with the larger one, may now become a problem as it become similar in size, and become its equal. With it now not being submissive to the large fish it may even start to push around the larger fish, which in some case, can't take being push around and at that point you're probably going to need to move one of the fish. Remember, fish do grow and some grow very large and quickly, and it doesn't take long for a small Tang, if feed properly and you have good conditions, to grow to a very large size.
Certain fish in the same group are more aggressive than others, which lets you mix them together as long as the other type aren't as aggressive. You see this with Triggers, larger Angels and Tangs, where you can mix a less aggressive fish together with a more aggressive one, as the less aggressive one will become subservient to the more aggressive one, but you probably would have a problem putting two aggressive fish together. Then again there are some that are very aggressive and their tank mates are very limited, even to the point where they maybe the only fish in the tank.
Different shapes and colors are also a good way of mixing fish, as fish that are similar in shape and colors may fight, while those that are different may not have any problems getting along. What fish eat can also play a part in keeping the same fish or fish from the same group together. Some fish will hog up all the food or push out other fish that eat what they're eating. You see this with fish like Gobies and Blenny.
In some fish mixing the same type of fish comes down to mixing pairs, male/female, otherwise they'll fight. You see this with fish where there is only one male and a bunch of females, as trying to place another male in the tank usually is a problem. Fish that eventually pair off, like Clowns do, can make it very hard to add another of the same fish or type, most of time either killing off the new fish that was added.
When picking fish you really needs to work up a plan. Before you start you should determine what fish that you want as you center piece and build around that fish. From there through research, and you should always do research before you buy anything, you can then determine what you can and can't add. You also need to be careful, as you'll see some people able to keep certain fish together, that normally wouldn't work, but it may just be that the fish have been together along time or just working for some reason, and it's probably not something that will happen in your tank. Remember there are no guarantees, fish are different, but something usually do follow true to form, if not in the beginning but in the lone run. Of course this usually leads to more tanks, which isn't a bad thing.