The College of Cardinals is supposed to pray for the guidance of the Holy Spirit when electing a pope. But God only directs them if that's what they want. There are always going to be bad apples (statistical probability) who place their own agenda above God and vote the way they want to.
Also, it appears from what we've heard that the cardinals didn't do due diligence re Francis. In this day and age of the internet, you would think it would be easy as pie to check on him to see what kind of bishop he was. Apparently they were too lazy, and just believed what they were told about him by those trying to orchestrate his election.
Doubtless insight.