As far as I can tell, the adverbs where, there, here seem to be from some Proto-Germanic locative case: the case that denotes the location at which an action occurs. Of course, grammatical cases work in certain ways by themselves, but have additional meanings when prepositions come into play.
Although Modern English is largely stripped of its cases, we still have little vestiges here and there.
'Where did you buy it?' means 'At which (place) did you buy it?'
'Where did you buy it from?' means 'From which (place) did you buy it?'
Evidently, both are correct. A traditional grammarian may dislike the second one for the postposition, but, since grammar is no longer part of the curriculum, only traditional grammarians know traditional grammar, and thus you have little to fear.
If you are curious, this is the traditional way of forming the second sentence:
'(From) whence did you buy it?'
But using whence in colloquial speech is tantamount to outcasting oneself.