It's basically just the way C works. str[5] is really equivelent to *(str + 5). Since str + 5 and 5 + str are the same, this means that you can also do *(5 + str), or 5[str].
It helps if you don't think of "5" as an index, but rather just that addition in C is commutative.