Team races in VS mode

I'm new to Mario Kart 8 and my SO and I find team races the most entertaining on 2player mode 50cc.

Is there a specific logic to how the teams are generated?

My team always loses, even when my player does well. It's quite frustrating. I'm trying my best to learn the logic behind the teams (I've had best results choosing similar player to my SO, but that usually just means my player competes well with opposing team, and my teammates all do terribly.

Any help/advice would be appreciated.