There's no contradiction between the propositions that (0) the source code of an algorithm is protected speech; and (1) there's specific ways of executing that code, effecting real-world consequences, that would be against the law.
Your point is most starkly clear in the case of any open source malware.
> (0) the source code of an algorithm is protected speech
An algorithm is uncopyrightable, as it is not a creative expression. Only creative expressions are copyrightable.
Copyright is a completely seperate part of the constitution than the first amendment. The one legal concept has nothing to do with the other.
You don’t just get to declare whatever legal interpretation you feel like.