“Être ou ne pas être, telle est la question”
Generally speaking
In French, the negation of infinitive verb is different than for other tenses. The negative form of “tu es” is “tu n’es pas”, not “tu ne pas es”. With infinitive, however, the “ne pas” is collected before the verb: the negative for of “être” is “ne pas être”, not “n’être pas”. Exceptions may apply, but in everyday speech I can’t think of any.
The negative form of “comprendre” is thus “ne pas comprendre” even though, when conjugated, the usual rules apply and the “pas” jumps behind the verb : “Je ne comprends pas”.
The same rules apply if you use “rien”. The correct infinitive form is “ne rien comprendre“, hence “c’est à n’y rien comprendre” ; the correct conjugated form is “il ne comprend rien”, which gives “personne n’y comprend rien”.
Mind “personne” however: “ne connaître personne“ is correct, “ne personne connaître" is not.
In this particular case
I would consider the extract “à n’y rien comprendre” to be idiomatic. The grammatical correctness of “C’est à n’y comprendre rien” could be debated, but in any case it would be really weird.