Hello @Barbara_Losi,
This is expected behavior. Subtasks do not actually belong to a project, unless they are intentionally added by pressing “Tab P” from the view pane and selecting said project.
I believe this was intentional to allow flexibility. Subtasks can sometimes be related to multiple projects or may just be detailed breakdowns that don’t always need project-level visibility.
If this is a feature you’d like to request, you can vote for a related request here: Allow to automatically add subtasks to project