I agree with Casscats on this.
Time to clarify some stuff. The fish we are talking about is the Siamese fighting fish and it's scientific name is normally considered Betta splendens. However, it is actually a hybrid between Betta splendens, B. imbellis and possibly a third species. The hybridisation occurred back in the 1970s and inbreeding has lead to the fish we currently see in shops today. Some fish have long fins, some have short fins (plakat). Betta imbellis is relatively peaceful for a bubblenest Betta species while B. splendens is much more aggressive. Some of the fish sold as B. splendens are peaceful like their B. imbellis ancestors, while others are aggressive like their B. splendens ancestors.
There's no way of telling if the fish you get is going to be peaceful like it's B. imbellis ancestors, or aggressive like it's B. splendens ancestors. So it is better to err on the side of caution and assume the fish will be aggressive and keep them on their own.
From now on in this post I will call the fish Betta or Bettas instead of using their full scientific name because they aren't actually a true species. If I refer to other species of Betta, then I will include their full scientific name (eg: Betta pugnax).
Fish kept in aquariums are stuck in a small enclosure compared to what they have in the wild. If you have a 10 foot long tank then you probably can keep a couple of male Bettas in the tank and they won't kill each other. However, if you stick them in an 18 inch long tank they most likely will kill each other. If the tank is heavily planted, particularly with plants near the surface, there will be fewer issues due to the fish not seeing each other as much and being able to set up territories that include sheltered areas.
Bettas naturally occur in areas with some floating plants or overhanging vegetation and they like to hide under the plants and ambush insects that land on the surface. If there are no surface plants, they are more likely to be stressed because predators like birds can see them from above. The same thing happens in an aquarium whereby the fish like to be near the surface (because they are labyrinth fishes) and they eat things that land on the surface. They eat other things in the water too but most of their diet consists of small insects that land on the water. If you were a small prey species and lived near the surface, you would want some protection to hide under so you don't get eaten too. It's in their DNA to behave like that and there's nothing we can do to change it. Just like they are labyrinth fishes, they need protection/ shelter from possible threats (regardless of if they happen in an aquarium or not).
If you put male or even female Bettas in a bare tank, they will stress out and can become more aggressive. If you put unrelated fish (fish that haven't been grown up or living together) into a tank they will become aggressive. If there is not enough room in the tank for all the fish to have a territory, they will become more aggressive. If you have a tank of mostly males and there is a female in there, there will be bloodshed.
In the wild male Bettas have their territories and defend it. If another male swims through the territory, the owner of that area will flare and display in an attempt to drive the intruder away. The intruder can either stay and fight, or swim away. They can swim away because there is plenty of water and room for the fish to get away. It's not trapped in a small glass box. If the intruder doesn't want to leave and both fish are similar sized and strength, they will fight. If neither party wants to surrender and leave the area voluntarily, they will fight to the death. This happens in aquariums too and I have seen it happen plenty of times to know that two adult male Bettas (and sometimes two females) kept in the same tank will probably harm each other, often to the point of death. This is in their genes and they are called Siamese fighting fish for that exact reason, they fight.
In various countries around the world they line breed aggression, short fins and speed into these fish so they can fight them. There is a huge amount of gambling associated with these fish and the gamblers (humans) want to see one fish kill another.
-------------------
PET SHOPS
Pet shops keep male Bettas separate so they don't damage each other's fins, don't kill each other, and so other fishes like black widow/ skirt tetras don't damage the Betta's fins. As mentioned by Casscats, damaged fins allow the entry of harmful microscopic organisms that can kill the fish. At the very least the fish loses value and might require medication to keep it alive. So male Bettas are kept separate to keep them safe.
Most pet shops keep female Bettas in single species tanks or mixed species tanks. The females are generally peaceful enough to get along for several weeks while kept in the shop aquarium. The stress of being in a shop tank is usually enough to help prevent the females setting up territories and developing a hierarchy, which changes every time a fish is added or removed from that aquarium. When the females are taken home and put in bigger tanks with fewer fish, they can set up a territory and develop a pecking order.
Most people that keep Bettas don't want a 10 foot tank to house two fish. They want a nice Betta in a small container on their desk so they can watch it. The fish are fine living like this as long as the container is at least 12 inches square and the water is kept clean. If people want several Bettas, they house them separately so they can't fight. Having a 2 or 3 foot long aquarium is not sufficient space for two male Bettas because their territory is normally around 24 inches in diameter. They need space and they need protection from each other and other types of fish.
On rare occasions some people might have two male Bettas live together in a small aquarium. This is not the norm and is usually pure luck with the two males having more in common with their B. imbellis ancestors.
Even when breeding, male Bettas will usually harass or kill the females after she has laid the eggs. The male doesn't want her in his territory and will try to drive her out of it after breeding. In an aquarium, the females are usually killed after breeding because they have nowhere to go, and the human must remove the female straight after breeding to prevent this from happening.
-------------------
STRESS AND CORTISOL
Regarding stress from fish seeing each other all day every day. Fighting and flaring (which is fighting), causes stress. Stress increases cortisol levels in animals. Long term exposure to high levels of cortisol weakens the immune system and it kills. All animals, birds, fish and reptiles can develop high cortisol levels and if fish are constantly stressed, they suffer from it too.
Just because your fish live for a year or two in aquariums that are next to each other and the fish see each other all the time, that does not make it a healthy living environment for the fish involved. Each time they fight/ flare their fins, their cortisol levels go up. If this is happening all day every day, the levels will be extremely high and be doing physical harm to the fish's body, even though we can't see the symptoms on the outside.
Think about being a kid at school and the school bully starts picking on you. Your stress levels go up, you can't concentrate properly, you might feel sick, you don't want to go to school. Your cortisol levels go up and you become physically ill. The same thing happens to fish that are constantly stressed through being housed inadequately or inappropriately.
Another example would be living next door to an annoying neighbour. Noisy parties all the time, excessive noise, smells, dog barking, etc. It causes stress and you usually call the police or council and it gets sorted out. Fish can't call the police or council and say my neighbour is threatening me every day, and they have to live with it simply because you want them to.
Male Bettas should not be housed next to each other if they can constantly see each other and constantly threaten each other. It causes them long term harm. They are not exposed to this type of scenario in the wild. In the wild, if a male fish comes into another male's territory, they either fight or one of the fish leaves. It is over in a matter of minutes unless there is a fight to the death, which can take as long as 30-60 minutes. After that the fish is no longer stressed and the cortisol levels can go down. It might be days or even weeks before another male comes through the area and this happens again.
The wild males do not get forced into an area and are not expected to live together with constant stress. This is what you are doing when you put males next to each other so they can constantly see each other. They are constantly stressed and their cortisol levels will be extremely high. The side effects of this high cortisol is a weakened immune system and an early death. Bettas can live for 5 or 6 years so if your fish live 2-3, they aren't living as long as they could and you have to ask yourself why.
If you want the males to flare for 5-15 minutes a couple of times a week, that is fine. Have a black divider between the tanks so they can't see each other, and remove the divider for a short time once or twice a week. Then put the divider back in place so the fish can't see each other. This replicates what happens in the wild most of the time. Two male fish encounter each other and show off for a bit, then they go their own way.