That's upsetting then. If bettas are supposed to live in 2-5 gallon tanks why do they always have them in tiny little jars and coke bottles? That's messed up
The reason they're kept like that at the store is because they can breathe air and it's easiest and cheapest to house them that way.
The reason people still keep them like that when they bring them home is because they're misinformed. Pet stores often don't tell people otherwise because bettas are a good seller due to people thinking it's ok to keep them in tiny jars and such. It's unethical, but a lot of stores only care about sales, and the employees don't necessarily know any better or do research into their proper care. Besides that, the employee turnover is so high at pet stores, that most of the people don't care to put the time into doing research into what they're selling, or worse the owners/managers don't want them "hassling" the customers by telling them something isn't ok.
Many breeders do keep the males in small enclosures because it's the easiest way to house several males, but they also do water changes daily to keep the water clean and the containers are usually in rooms that are heated to a specific temperature. Or the fish are on a "system" consisting of several containers linked together, where water is constantly filtered and changed out. Even in this case I don't necessarily think it's best for the fish to house them in such small containers, but at least the water is kept clean, unlike the majority of containers bettas are kept in at the average home. For the average person with only one or a few bettas there's no reason to keep them in such a small unheated enclosure.