"Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety." - Benjamin Franklin
Exactly this. Compromising a society’s core beliefs in order to protect them is inherently self-defeating, and is just a justification of fascism.
To implement mandatory mindscans would remove all good faith and trust, and be an invasion of privacy contradictory to the core beliefs of the Federation. They wouldn’t have to wait for an infiltrator to compromise what they stand for, they would have already done so themselves.