It’s not really bad programming, since it is very likely intentional. The matchmaker / balancer tries to give players an equal amount of wins and losses over time, not make one particular round balanced. So it creates lopsided teams.
After bf1 came out, there was a guy on youtube (I don’t remember his name) who pointed out that a few years before bf1 came out, EA patented a system like that. The reasoning is that if a player only wins, they get bored, and if they only lose, they get bored, to keep people playing more the balancer tries to give players a mix of wins, losses and draws.
TL:DR the system isn’t designed to create balanced matches, its designed for “player retention”. It’s not terrible programming, just a bad game design decision.