I'm not a fan of this idea, there are many times I join lobbies as Heavy depending on the Medic.
i.e. Me and my friend like to go Heavy Medic together on lobbies, if this feature was enabled, then it would ruin it for me and her. Yes, you can argue "just don't join a lobby with this feature enabled" but is this really necessary? If the lobby leader feels there is a stack, they can take action themselves rather than having a randomized feature enabled as soon as they create the lobby.