The Prophet ﷺ used to copy the people of the Scriptures in matters in which there was no order from Allah. The people of the Scripture used to let their hair hang down while the pagans used to part their hair. So the Prophet ﷺ let his hair hang down first, but later on he parted it.
كَانَ النَّبِيُّ ﷺ يُحِبُّ مُوَافَقَةَ أَهْلِ الْكِتَابِ فِيمَا لَمْ يُؤْمَرْ فِيهِ وَكَانَ أَهْلُ الْكِتَابِ يَسْدِلُونَ أَشْعَارَهُمْ وَكَانَ الْمُشْرِكُونَ يَفْرُقُونَ رُءُوسَهُمْ فَسَدَلَ النَّبِيُّ ﷺ نَاصِيَتَهُ ثُمَّ فَرَقَ بَعْدُ