When called without argument, they return child indices in the position’s parent node. So for positions that fall between nodes, they’ll return the same value. For positions inside a text node, indexAfter will be one more than index().
If you pass an argument to select an ancestor node further up the tree, indexAfter is always one more than index, because the position points into a child of that node.
I have been scratching my head to think about this until I found this explanation. I suggest we should add this to the doc of the method, because IMHO the source code is not that self-describing …