They use machine learning to see which code patterns follow other code patterns and then make suggests based on that. "Oh, I see you've written X. Most people who write X follow it with Y."
However, this requires reading people code that they upload to their servers. See their privacy policy here: https://kite.com/privacy.