Joshua had to choose between serving the true God or worshipping false gods. Joshua’s goal was to stay close to Jehovah; hence, he chose a path that took him in that direction. Cain had no such goal, and he chose the path that took him farther away from Jehovah.
تَخَيَّلْ مَثَلًا رَجُلًا يَمْشِي فِي ٱلطَّرِيقِ ،‏ وَإِذَا بِهِ يَجِدُ نَفْسَهُ فَجْأَةً أَمَامَ مُفْتَرَقٍ تَتَشَعَّبُ مِنْهُ طَرِيقَانِ .‏