Here's a post that might help you - https://www.familyhandyman.com/floor/floor-repair/how-to-repair-squeaky-stairs/#targetText=screw%20through%20the%20riser%20into,the%20stringer%20to%20each%20stud.
Do you have exposed wood treads or are they carpeted?
In either case, nails have been naturally “pulled” from the changes in the wood’s humidity and people walking on the stair.
Therefore, no more nails.
I would screw the treads into the risers, pre-drilling the holes (under drill). From the backside I would screw the risers into the treads.
Sink & Fill the screw heads with wood putty & finish to match.
This link should help:
Get under them and screw the loose boards
the under part of the steps are covered with a ceiling/plywood and painted. So I can’t go under