If you read closely, the two statements doesn't even contradict. S(he) said that it's good that you are the best AT SOMETHING. You said, it's not good to be THE BEST.
Because they have more work than they can handle and want you to fill in their shoes at some point in time. That is the basis of hiring junior developers.
If you're starting with a new career, learning on the job, it's not good if you're the smartest in the room. Then you need to find a place where other people can teach you.
It can also be read as a ego-booster. If you know the most of all people about basketball at a birthday party, it's a cool thing to talk about.
It's not as black/white as you're making it out to be. Reality is far more nuanced.
The idea isn't about surrounding yourself with people who are worse than you, just so you can say you are "the smartest person in the room". The idea is to focus on something and become so good at thing that you are -usually- the "smartest person in the room" on that particular topic. Which means this whole idea is only relevant to contexts that your thing is relevant. And to reiterate, this is more of an aspiration than something that's literally achievable. In reality, with a vanishingly small number of exceptions, there will always be at least one person who knows more than you about thing. And that's OK. The point is about focus and the importance of putting in the work vis-a-vis your thing.
What happens with classroom professors or surgeons in surgery rooms? Should they leave the room as well?