He wasn't a real anarchist, just a loony tune. He killed McKinley not for political reasons,but because McKinley wouldn't give him a job. Czolgosz was convinced that he should be McKinley's biographer. He thought that McKinley was a personal friend of his and wrote tons of letters to him as if they had been close for years. He even customized a gem-studded gun with which to perform the assassination. He would talk to the gun as if it were his friend as well. I've always thought his life would make an excellent movie, maybe in the hands of the Coen Brothers.
They tied him to anarchism because they wanted to get rid of all the anarchists. Shortly after the assassination, that's exactly what they did.
All part of Edison's relentless campaign to alert the public to the dangers of alternating current. Edison would refer to electrocution as being "Westinghoused to death."