Every time I enter an url into safari it goes to a previously visited part of it
It is normal. It allows you to get to pages you previously visited or, if you prefer to visit only the URL you've typed thus far, you simply hit backspace and then enter.

Safari's autocomplete model is slightly un-ntuitive at first (especially if you're used to shell completion) because it offers not the shortest unique completion but something else which is almost always longer. 

From my non-scientific observation, I'd say the algorithm most likely uses the most visited URL which matches what's already been typed or, all being equal, the most recently visited.  Which makes a lot of sense when you think about it AND understand that you can always ignore Safari's guess by either continuing to type or hitting backspace.