It does as the north-eastern part of Kashmir is held illegally by Pakistan. Since the whole of Kashmir, Jammu and Ladakh belongs rightfully to India, Afghanistan does border Inida.
It might be 'illegally held' as you say, (im not getting involved in this) but Pakistan controls the land there, and India then does not border Afghanistan because they cant do anything there. Part of sovereignty includes controlling the land.