A task can be linked to a project in several ways.
In the overview of all tasks, you can directly select and link the task to a project in the table by pressing the + symbol in the project column.
In task details, you can select and press the drop-down list with an overview of projects and select a project.
You can create a task directly into a project.
A task can always be removed from a project by removing a link, in the same way as adding it as in point 1 or 2.