The single best evidence is injury and deformity.
You can lose any other part of the body without impairing cognition but brain damage especially damage to specific parts of the brain alter or damage cognition. Losing a foot or a kidney or an eye does not suddenly make you unable to speak, but damage to the language center of the brain does. Cataloging the effects of damage to different parts of the brain has actually given a fairly decent map of what different parts of the brain do before we started scanning active brains.
<
<
Animal brain removed from their bodies and connected to circuitry can learn.
As for how can we be certain, we can't, that's not how science works. We can say it is extremely likely given existing evidence and there is no evidence to the contrary, to the point it can be safely assumed, but science does not deal in absolute certainty.