Rashi says on the posuk (בראשית,ד,כ) of:
וַתֵּ֥לֶד עָדָ֖ה אֶת־יָבָ֑ל ה֣וּא הָיָ֔ה אֲבִ֕י יֹשֵׁ֥ב אֹ֖הֶל וּמִקְנֶֽה
וּמִדְרַשׁ אַגָּדָה בּוֹנֶה בָתִּים לַעֲ"זָ, כְּמָה דְּאַתְּ אָמַר סֵמֶל הַקִּנְאָה הַמַּקְנֶה (יחזקאל ח'), וְכֵן אָחִיו תּוֹפֵשׂ כִּנּוֹר וְעוּגָב לְזַמֵּר לַעֲ"זָ
There is a Midrashic statement (Genesis Rabbah 23:3) that he built temples for idol worship, (for ומקנה may be read ומקנה –– provoking jealousy), just as you say, (Ezekiel 8:3) "the image of jealousy which provoketh God to jealousy" (המקנה); similarly his brother handled the harp and guitar to make music for idol worship.(translated by Sefaria)
However, later on the posuk (ד,כו),
אָ֣ז הוּחַ֔ל לִקְרֹ֖א בְּשֵׁ֥ם יְהוָֽה...
לְשׁוֹן חֻלִּין, לִקְרֹא אֶת שְׁמוֹת הָאָדָם וְאֶת שְׁמוֹת הָעֲצַבִּים בִּשְׁמוֹ שֶׁל הַקָּבָּ"ה לַעֲשׂוֹתָן עֲ"זָ וְלִקְרוֹתָן אֱלֹהוּת
The word הוחל must be connected in meaning with חולין “profane matters “) viz, calling the names of men and the names of idols after the name of the Holy One, blessed be He — making them the objects of idolatrous worship and calling them Deities (Genesis Rabbah 23:7).(translated by Sefaria)
The Gur Aryeh clarifies Rashi by saying:
אף על גב דלשון זה הוא התחלה לפי פשוטו - מכל מקום לכך כתב לשון "הוחל" כי התחלה זאת הוא חלול, וכבר הראיתך (אות כג) כי זה דרכי התורה, והוא יסוד גדול מאד לכתוב לשון נופל על לשון,
Even though this [word הוחל] is simply understood as a language of 'beginning' - nevertheless, for this reason it wrote הוחל [as opposed to just writing אז קראו בשם ה, and it would be understood that that was when it started], because this beginning is [the beginning of] desecration, and I have already shown you that this is the way of the Torah [to write a word that is understood on its simple meaning, but because it could have been written in a better way, it hints to something else] and it is a very big יסוד (I am not sure how to translate this word) that [the Torah] writes a language which hints to something else which is a similar word.
So, how can posuk כו say that עבודה זרה only started later?