Nobody knows. Nobody understand it.
Seriously now, it looks like bulkier pokemon that make little or no damage have always priority. It used to like Rhydon in the past, it currently likes Aggron. It likes making the fight the longest and ineffective possible. It never selects machamp against blissey because it assumes that we don't know how to dodge. Enemy pokemon in a gym that you are meant to fight the last, have priority in the selection...
Nobody likes the auto select.