I thought it should be “Je viens du acheter”. Is it because “acheter” has a vowel at the beginning?
De le becomes du only when le is an article, meaning "the". In this case le is a pronoun, meaning "it" (the book).
This sentence contains the particle de (part of the verb venir de) followed by the personal pronoun l' followed by the verb acheter. The usual form of this pronoun is le when referring to a masculine noun, and la when referring to a feminine noun. However, when the article is followed by a word that begins with a vowel, the pronoun is always elided to l'. The form l' exists for both genders.
This elision is also done when le or la is a definite article: le matin, la nuit, l'après-midi. It is also done when le or la is part of a partitive article: du pain, de la confiture, de l'eau.
Now let's suppose the verb didn't start with a vowel: “je viens de le vendre”. Why don't we say “je viens
On the other hand, there is no contraction when de and le happen to be next to each other but they do not form a single unit. Here, de is part of the verbal compound venir de and le is a personal pronoun which forms a complement of this verb. There is no contraction when le is a pronoun: “je viens de le vendre”.
You are right about the vowel part, consider these two examples:
However, in your example the words "de" and "l'" are not linked at all, so you can't replace them by "du".
Consider these two examples:
Here "de" isn't quantitative but is used to introduce another subsentence, here "manger".
So they have no relation, and you can't say, for example:
But you need to say: