sklearn.neighbors.NearestNeighbors may have a bug

### Describe the bug

I found a suspected error in NearestNeighbors:
``` python
from sklearn.neighbors import NearestNeighbors
nbrs = NearestNeighbors(n_neighbors=2).fit(yields[if_predict == -1][:130])
distances, indices = nbrs.kneighbors(yields[if_predict == -1][:130])
print(indices[:, 0])
```
Execution result:
``` py
[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 121 123 124 125 126 127 128 129]
```
There are two "121" in the above

### Steps/Code to Reproduce

``` python
from sklearn.neighbors import NearestNeighbors
nbrs = NearestNeighbors(n_neighbors=2).fit(yields[if_predict == -1][:130])
distances, indices = nbrs.kneighbors(yields[if_predict == -1][:130])
print(indices[:, 0])
```

### Expected Results

The result should be a continuous integer, how can there be repetition?

### Actual Results

``` python
[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 121 123 124 125 126 127 128 129]
```

### Versions

```shell
System:
    python: 3.9.19 (main, May  6 2024, 20:12:36) [MSC v.1916 64 bit (AMD64)]
executable: D:\software\python\anaconda3\envs\quantitative\python.exe
   machine: Windows-10-10.0.19045-SP0

Python dependencies:
      sklearn: 1.5.2
          pip: 24.0
   setuptools: 69.5.1
        numpy: 2.0.2
        scipy: 1.13.1
       Cython: None
       pandas: 2.2.2
   matplotlib: 3.9.2
       joblib: 1.4.2
threadpoolctl: 3.5.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 8
         prefix: libscipy_openblas
       filepath: D:\software\python\anaconda3\envs\quantitative\Lib\site-packages\numpy.libs\libscipy_openblas64_-caad452230ae4ddb57899b8b3a33c55c.dll
        version: 0.3.27
threading_layer: pthreads
   architecture: Haswell

       user_api: openmp
   internal_api: openmp
    num_threads: 8
         prefix: vcomp
       filepath: D:\software\python\anaconda3\envs\quantitative\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None

       user_api: blas
   internal_api: openblas
    num_threads: 8
         prefix: libopenblas
       filepath: D:\software\python\anaconda3\envs\quantitative\Lib\site-packages\scipy.libs\libopenblas_v0.3.27--3aa239bc726cfb0bd8e5330d8d4c15c6.dll
        version: 0.3.27
threading_layer: pthreads
   architecture: Haswell
```

COMMENT:
```python
nbrs = NearestNeighbors(n_neighbors=2).fit(yields[if_predict == -1][:130])
distances, indices = nbrs.kneighbors(yields[if_predict == -1][:130])
print(distances[:, 1])
print(distances[:, 1][121])
print(distances[:, 1][122])
```
results:
```python
[ 0.36002541  0.29094663  1.80166781  0.44075349  0.44075349  1.59734321
  2.06097984  2.98478508  3.88138819  1.26152861  2.68546057  0.89800495
  0.72063476  1.35180736  6.27232027  0.72063476  1.37337458  0.81492561
  0.78976673  3.68325758  0.95021188  1.01082158  0.16239107  0.31097171
  1.77247822  0.23424578  0.23424578  2.42504382  0.05312405  0.54023629
  0.25460219  0.25460219  1.57535362  0.31097171  0.72385734  1.32017827
  0.03622784  1.57916284  0.36002541  1.60123122  0.90614694  0.19651891
  0.19651891  1.03063416  1.2346431   1.43783033  1.28908873  1.0621469
  2.98981667  2.54391313  1.26152861  0.16622268  0.17204921  0.16622268
  0.82462752  1.69951808  0.54023629  2.68559408  0.05312405  1.57249045
  1.46622872  0.30018437  1.04888391  0.87051725  2.01888633  1.20337868
  0.8011145   1.43201959  0.16239107  0.29094663  0.09890013  0.09890013
  7.60956144  1.27005243  0.85553056  1.59463322  0.86229932  3.60835409
  1.756441    1.65817714  3.77676725  0.77282447  1.78103912  0.72892576
  2.12609673  0.8060016   2.2035737   0.03622784  1.03236663  1.49741948
  2.48670912  9.50325298  6.08657598  0.47002029  0.75094658  1.16635168
  0.10514245  0.10514245  4.97962999  2.32827139  1.16635168  0.29954025
  0.29954025  1.04888391  2.59600997  1.37993562  0.57942271  0.30018437
 23.76122093 11.79220963  0.47002029  0.43145591  0.78976673  0.43145591
  1.90235066  0.07554037  0.07554037  2.37019038  1.24407279  6.37225771
  0.52648044  0.          0.          1.45298481  1.24407279  1.1395483
  0.82462752  1.63532209  0.82888484  2.13054323]
0.0
0.0
```
The 121st value of distance is 0

Labels: Bug, Needs Triage