Fourier's basic theorem is that any (non-pathological) waveform can be decomposed into the sum of sinusoids, even waveforms that look nothing like a sinusoid. In the finite-sized discrete case (DFT), there are a finite number of sinusoidal basis vectors, and any signal can be decomposed into them, including non-sinusoidal waveforms, as well as segments of sinusoidal waveforms of different frequencies from those of the basis vectors.
So your basic confusion might be in expecting the DFT to be a "search" for a single basis solution, instead of a decomposition into a bunch of sinusoids that individually might or might not resemble the input closely, or at all.
However, if there are some reasonably close matches among the basis sinusoids, searching x[i] of thea DFT magnitude result might find the one with the closest match or fit, which, itself, again, need not be an exact match. So need not be your "expected" one.