The tasks on the command line are selectors, so when you run gradle projectTask, Gradle is trying to find all tasks with that name in all subprojects. When you run with gradle :projectTask, that’s selecting the task with the path “:projectTask”.
So you don’t really know if your task was selected one way or the other and it shouldn’t matter. Your task is associated with a particular project, so you typically make it work relative to that project. If you have a multi-project build, there will be several, separate instances of your task.