This is a very difficult comparison because the men had such different backgrounds and held such different places in society as adults. One way to compare them is to say that Kennedy was the ultimate insider while Malcolm X was the ultimate outsider.
Kennedy was a member of the elite his whole life. His father was a wealthy businessman who was, for a time, the US Ambassador to Britain. By contrast, Malcolm X was born to an obscure black family that had nothing like elite status in society.
As adults, the men were just as different. Kennedy went into politics soon after serving in WWII. He rose quickly, helped by family connections. His was a very "establishment" career. By contrast, Malcolm X was convict who went on to be a Black Muslim and a black nationalist. This is the epitome of "outsiderness."
In short, then, the best way to compare the two is to say that Kennedy lived his whole life in the elite levels of mainstream America while Malcolm X's life was the polar opposite.